Problems with walkspeed script

here’s my script:

local part = game.Workspace.Part

local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()

local h = char.Humanoid

function onurmom()
h.WalkSpeed = 100
else
h.WalkSpeed = 16
end

part.MouseButton1Click:Connect(onurmom)

You’ll need to add a Clickdetector to the part. Then do part.ClickDetector.MouseClicked.

1 Like

what about the else part incase walk speed is already 100

What is the “else” checking? I don’t see an if statement.

1 Like

This is what you do in that case:

part.ClickDetector.MouseClicked:Connect(function(player)

if player.Character.Humanoid.WalkSpeed == 100 then
    player.Character.Humanoid.WalkSpeed = 16
else
    player.Character.Humanoid.WalkSpeed = 100
end

end)
1 Like

ohh ok thank you for help you too keneyaz