Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

These running event if then statements aren't functioning?! Help

The script below isn't running, why?

local player = game.Players.LocalPlayer
local hum = player.Character.Humanoid

hum.WalkSpeed.Running:Connect(function()
if hum.WalkSpeed < 17 then
	script.Parent.Disabled = true
end
end)

hum.WalkSpeed.Running:Connect(function()
if hum.WalkSpeed > 17 then
	script.Parent.Disabled = false
end
end)

1 comment

0

This isn't working probably cause when the players walk speed is at 16 then the script disables but it will stop working after that so if u change the players walk speed after that, it won't work.....................................

2 answers

✓ Accepted answer

make it a loop, that should do it, also, good job for adding script.Parent.Disabled, instead of the script itself

it should loop something like this

while wait() do
local player = game.Players.LocalPlayer
local hum = player.Character.Humanoid
hum.WalkSpeed.Running:Connect(function()
if hum.WalkSpeed < 17 then
    script.Parent.Disabled = true
end
end)

hum.WalkSpeed.Running:Connect(function()
if hum.WalkSpeed > 17 then
    script.Parent.Disabled = false
end
end)
end)

1 comment

0

    Your idea was amazing, but this is the correct way, local player = game.Players.LocalPlayer local hum = player.Character:WaitForChild("Humanoid") while wait() do if hum.WalkSpeed < 17 then script.Parent.Disabled = true elseif hum.WalkSpeed > 17 then script.Parent.Disabled = false end end

Running isn't an event, so you can't make it a function.

if hum.WalkSpeed < 17 then
script.Parent.Disabled = true
end

else

if hum.WalkSpeed > 17 then
script.Parent.Disabled = true
end

Im pretty sure this will work, just remember that you can't just make anything like running an event

1 comment

0

Running is a Humanoid event and your edit definitely not work because there is an "end" before the else. @XGodofGods

This discussion is preserved as it was. New answers, comments, and votes are closed.