i am trying to see how i can make a walkspeed increase by a click of a button!
heres my script so far that doesnt work:
local newWalkspeed = 50
script.Parent.MouseButton1Click:Connect(function()
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild(“Humanoid”).WalkSpeed = newWalkspeed
end)
end)
end)
hope you can fix it
I’m going to assume that you’re using a LocalScript to achieve this (as that is what will allow you to use UI click functions). A great feature of LocalScripts is their “LocalPlayer” call. That way, you can call game.Players.LocalPlayer and know it’s the person who clicked the UI element. Implementing this into your code, you have:
local newWalkspeed = 50
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”).WalkSpeed = newWalkspeed
end)
1 Like
THANKY YOUUUUUUU thanks so much
1 Like