so, I have made a button so that when you touch it, you go faster, and after about 1 second, you stop. But, the walkspeed is just set to my faster one and doesn’t return to its default. (And, I have it so even if you aren’t running, itll automatically walk for you, but that doesn’t work. help would be appreciated.) script:
script.Parent.Touched:Connect(function(touch)
local Humanoid = touch.Parent:FindFirstChild("Humanoid")
Humanoid.WalkSpeed = 85
Humanoid.Running = true
wait(1)
Humanoid.WalkSpeed = 16
Humanoid.Running = false
end)
Alright, a couple of things here.
-
Running is an event of Humanoids, not a property, so you can’t set it to a boolean.
-
You aren’t checking that a humanoid exists, so make an if statement.
if Humanoid then
--Code
end
Fix this stuff and see if it works then.
The humanoid walkspeed is still stuck at 85. and, how will I make the player move automatically?
I assume you mean I could not touch my keyboard, and the player would move. If that’s the case, try something like: Humanoid | Documentation - Roblox Creator Hub
or
Humanoid | Documentation - Roblox Creator Hub
The first one make the player go in a particular direction. The second one will make the player move to a specific location.
I recommend you look into: Humanoid | Documentation - Roblox Creator Hub as well, as these two functions are listed there.
Finally, you’re players speed might be stuck as you’ve not added a debounce to your touch script. With something like this, a debounce to prevent it from running more than once is very important (especially because the Touched event is a bit… well touchy
Hope this helps!
1 Like