Script only working once and never again

My code works once! But then when the walk speed resets it does not work again. (normal script)

this is the code that resets the speed (local script)
image

the if statement will only run once is from what I am understanding.

  1. Is the moving == false script in the same script as the touched one?
  2. Could you use code blocks next time, images are fine, but it allows people to help faster.
    ( if you didn’t know a code block is made by typing ``` )

For the if statement to run more times, it needs to be ran from a while true loop or a function. ( like how if you touch a part, something happens )

A simple solution would be:

while wait() do
if moving == false then
print("random stuff here")
end

This is because you are resetting the speed on the client, the server does not know that the speed is 60 on the client so it sets 100 to 100. You should use a remote event to change the players walkspeed on the server.

Hope this helps :slight_smile:

Server Script:

script.Parent.Touched:Connect(function(hit)
	hit.Parent.Humanoid.Walkspeed = 100
	hit.Parent.Humanoid.MaxSlopeAngle = 150
	script.launch:Play()
end)

game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(player)
	local character = player.Character
	
	character.Humanoid.Walkspeed = 60
        character.Humanoid.MaxSlopeAngle = math.clamp --// i cant read the rest of the code in the image
end)

Then in the local script you would fire the remote event using :FireServer()

Sorry for the late reply by the way, I wanted to help when you originally made this post but I had to get devforum member first!