Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a button that sets your walkspeed ?

Asked by 4 years ago
Edited 4 years ago

(on a gui) i am stuck with this :

local walkbtn = script.Parent local player = game.Players.LocalPlayer local Character = player:WaitForChild("Character") local humanoid = Character:WaitForChild("Humanoid")

walkbtn.MouseButton1Down:connect(function() humanoid.WalkSpeed = 100 end)

and it dosnt work pls dont bully me am trash at scripting

0
Consider clicking accept answer on the answer that helped so both you and the answerer gets reputation moo1210 587 — 4y

2 answers

Log in to vote
0
Answered by
moo1210 587 Moderation Voter
4 years ago
Edited 4 years ago

You're using WaitForChild on a property, not a child. All you need to do is to replace local Character = player:WaitForChild("Character") with local Character = player.Character. Your also using a script as you showed earlier, change to a localscript.

0
Then your using localplayer on a script, not a localscript, change to a localscript. moo1210 587 — 4y
0
do you have discord? Scorched_Liam 19 — 4y
0
" This will return nil if the character hasn't loaded yet" Hes calling the player not the character, a player can exist without a character. moo1210 587 — 4y
0
ty it works now Scorched_Liam 19 — 4y
Ad
Log in to vote
0
Answered by
Norbunny 555 Moderation Voter
4 years ago

"Character" is not a child of player.

Instead do

local character = player.Character or player.CharacterAdded:Wait() -- waits for the character to load
0
this still doesnt work Scorched_Liam 19 — 4y
0
Might want to share any errors showing up. Norbunny 555 — 4y
0
local walkbtn = script.Parent local player = game.Players.LocalPlayer local Character = player.Character or player local humanoid = Character:WaitForChild("Humanoid") walkbtn.MouseButton1Down:connect(function() humanoid.WalkSpeed = 100 end) so like this Scorched_Liam 19 — 4y
0
You didn't use my fix. it's not "or player", it's "or Player.CharacterAdded:Wait()" Norbunny 555 — 4y

Answer this question