#help me! I want this script as mobile button! (its a sprint button with stamina)

1 messages · Page 1 of 1 (latest)

high river
#

local UIS = game:GetService('UserInputService')
local Bar = script.Parent:WaitForChild('Sprint'):WaitForChild('Bar')
local player = game.Players.LocalPlayer
local NormalWalkSpeed = 16
local NewWalkSpeed = 20
local ii = 10
local running = false
repeat wait() until game.Players.LocalPlayer.Character
local character = player.Character

--// FUNCTIONS \--

UIS.InputBegan:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
character.Humanoid.WalkSpeed = NewWalkSpeed
running = true
while ii > 0 and running do
ii = ii - .03
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 42, 42), 0.001)
wait()
if ii <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)

UIS.InputEnded:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
character.Humanoid.WalkSpeed = NormalWalkSpeed
running = false
while ii < 10 and not running do
ii = ii + .03
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 166, 11), 0.001)
wait()
if ii <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)

plush cliff
# high river local UIS = game:GetService('UserInputService') local Bar = script.Parent:WaitFo...

Much more easier than you think, I wont spoonfeedit to you but ill tell you what to do

First off
make the stamina stuff a function that can be called easily

then have two inputs that connect to the function


local Active = false

then check if a player touches the button, make the variable true, else if clicked again make it false

for keyboards... ehhh.. keep the same inputs.

i dont know if this made sense but.. you figure it out.

high river
#

it is gui button...

#

pls script if you can

plush cliff
#

Make a textbutton / imagebutton

high river
#

have it

plush cliff
#

and try to add the stuffs i said, but i dont know tho ima bit sleepy and woozy

high river
#

can you write it to me tommorow or? (the script) or what?

plush cliff
#

If your really desperate just ask chatgpt.

plush cliff
high river
plush cliff
high river
#

no?

plush cliff
#

The script works entirely okay by itself , But you really need to think on how to do it.

#

Again just try to add on what i said on how to fix this, Its just what i can think of as of the moment, dont know if it will be fixed or not

high river
#

what will i say to the chatgpt to work the sprintButton?

plush cliff
#

If you have troubles on it.. i suggest going to docs or watching a scripting tutorial.

high river
#

ok

#

if i have this?: local UIS = game:GetService('UserInputService')
local Bar = script.Parent.Parent.Parent.Stamina.Sprint.Bar
local player = game.Players.LocalPlayer
local NormalWalkSpeed = 16
local NewWalkSpeed = 20
local ii = 10
local running = false
repeat wait() until game.Players.LocalPlayer.Character
local character = player.Character

local sprintButton = script.Parent

local function startRunning()
character.Humanoid.WalkSpeed = NewWalkSpeed
running = true
while ii > 0 and running do
ii = ii - .03
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
wait()
if ii <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end

local function stopRunning()
character.Humanoid.WalkSpeed = NormalWalkSpeed
running = false
while ii < 10 and not running do
ii = ii + .03
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
wait()
if ii >= 10 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end

sprintButton.MouseButton1Click:Connect(function()
if running then
stopRunning() -- Stop running if already running
else
startRunning() -- Start running if not already running
end
end)
it writed chatGPT

#

?

plush cliff
coral tapir
#

that are deprecated

#

like wait and tweensize

#

also does mousebutton1click work on mobile anyways

#

ik that .Activated is same thing and works on both pc and mobile

hasty valley
#

I have universal spring button script

#

Work for all Davices

#

@high river