#so im making a stamina run scirpt
1 messages · Page 1 of 1 (latest)
so
I do not see the whole script
but by the error I can assume that
you got a function and a boolean variable called the same
this makes the script confused making it think you are trying to call a variable as a function
and spits the error
however it would be really ok if I could see the whole script
@silver obsidian
just as I though
so, on the first picture you can see there is a variable called "sprint" which has the value false, right?
yeah
and on the second image there is a function that is also called sprint
this makes the script confused
the way to fix this would be changing any of the names
I'd change the function name
Change the thing in red to other name
and here, change 'sprint' to the new name you just placed
that should fix it
nope unless im doing it wrong
** You are now Level 3! **
send me the whole script on a single message, copy paste it this way
so it gets sent with a block
** You are now Level 17! **
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local player = game.Players.LocalPlayer
local character =player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local pg = player.PlayerGui
local stamina = 100
local maxstamina = 100
local speed = 8
local drain = 20
local refresh = 10
local staminaregen = 0
local move = false
local sprinting = false
local tired = false
local function move(active)
if tired then return end
humanoid.walkspeed = active and humanoid.walkspeed + speed or humanoid.walkspeed - speed
sprinting = active
end
local function onInput(input)
if input.UserInputType == Enum.UserInputType.Gamepad1 or input.KeyCode ~= Enum.KeyCode.LeftShift then
move = input.userInputState == Enum.UserInputState.Begin
move(sprinting)
end
end
local function updateStaminaUi()
game["StarterGui"].energy.frame.staminabar.Size = UDim2.new(math.clamp(stamina / maxstamina, 0, 1), 0, 1, 0)
game["StarterGui"].energy.frame.percent.Text = tostring(math.floor(stamina)) .. "/" .. tostring(math.floor(maxstamina))
end
game.UserInputService.InputBegan:Connect(onInput)
game.UserInputService.InputEnded:connect(onInput)
game["Run Service"].Heartbeat:connect(function(DeltaTime)
if sprinting then
stamina = math.max(0, stamina - drain * DeltaTime)
updateStaminaUi()
print(math.floor(stamina))
if stamina == 0 then
move(false)
tired = true
end
else
stamina = math.min(100, stamina + refresh * DeltaTime)
if stamina >= staminaregen then
updateStaminaUi()
tired = false
print(math.floor(stamina))
if sprinting then
move(true)
end
end
end
end)
that also works I guess
oh liek dm you personly
huh?
how
local rs = game:GetService("RunService")
local player = game.Players.LocalPlayer
local character =player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local pg = player.PlayerGui
local stamina = 100
local maxstamina = 100
local speed = 8
local drain = 20
local refresh = 10
local staminaregen = 0
local move = false
local sprinting = false
local tired = false
local function move(active)
if tired then return end
humanoid.walkspeed = active and humanoid.walkspeed + speed or humanoid.walkspeed - speed
sprinting = active
end
local function onInput(input)
if input.UserInputType == Enum.UserInputType.Gamepad1 or input.KeyCode ~= Enum.KeyCode.LeftShift then
move = input.userInputState == Enum.UserInputState.Begin
move(sprinting)
end
end
local function updateStaminaUi()
game["StarterGui"].energy.frame.staminabar.Size = UDim2.new(math.clamp(stamina / maxstamina, 0, 1), 0, 1, 0)
game["StarterGui"].energy.frame.percent.Text = tostring(math.floor(stamina)) .. "/" .. tostring(math.floor(maxstamina))
end
game.UserInputService.InputBegan:Connect(onInput)
game.UserInputService.InputEnded:connect(onInput)
game["Run Service"].Heartbeat:connect(function(DeltaTime)
if sprinting then
stamina = math.max(0, stamina - drain * DeltaTime)
updateStaminaUi()
print(math.floor(stamina))
if stamina == 0 then
move(false)
tired = true
end
else
stamina = math.min(100, stamina + refresh * DeltaTime)
if stamina >= staminaregen then
updateStaminaUi()
tired = false
print(math.floor(stamina))
if sprinting then
move(true)
end
end
end
end)```
this is because you have the same problem with other function
so
it says the error is at line 21
31*
in that line you call a move function
but above the script there is also a variable called move
it is the same mistake
the same solution
so what do i name it then
yeah i know
up to you, you can name the variable like moving
and replace every other place where you use the variablw
what variable
the one at top
that is called move
you can change it to moving
or smt like that
btw this line
I think it is wrong
that syntax makes no sense
what are you trying to achieve in there
lets leave it like that for now and if it spits an error then we fix it
um i changed it but its still giving me the same error
so, above that line exists the problematic line
that still makes a new variable called the same
is this variable and the one at top the same one?
like you're overwriting it?
and the function is also named move
no
you changed the function name?
alright so
same error
on this line also change the name
witch one
welp thx but now i have aother error i might just start over
you do not name it walkspeed
it is WalkSpeed
change walkspeed -> WalkSpeed
capitalization is important
oh okay hold
okay that worked but now ever whenevr i click something i stop moving and cant move after wards
I do not see any place where theres a click event
It is probably on another script
that is something with another script
also on these lines change move() to moveing() also
any errors on output when you click or jump?
yeah when i jumped i stoped moving
nope still stop even after repalcing it
shouldi send you the renewed version of the script
thats a problem with the movement system but I do not have that script
so I cannot help you with that
okay thanks for your help i can atleast learn from this but now i got to scrap this witch is whatever cya man
alright