I got this error {Expected 'end' (to close 'function' at line 4), got 'else'}.
I'm sorry if this is a really simple and easy solution, but I don't know. I made a simple sprint and it worked and then I continued to work on it so that the player change the speed back to normal. But then I got this error and it stopped working.
This is my script in its entirety:
local var_x = 0
while true do
wait(1)
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcesed)
if var_x == 0 then
if input.KeyCode == Enum.KeyCode.X then
game.Player.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 50
local var_x = 1
end
end
else then
if input.KeyCode == Enum.KeyCode.X then
game.Player.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 17
local var_x = 0
end
end
end
I know it's just a simple sprint button but I'm still confused.

1 comment
Thank you so much. You were a great help.