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

How to Increase walkspeed per Click on GUI?

Asked by 6 years ago
Edited 6 years ago

Well I tried a lot of time to find out how to do it but I can't really understand can someone help me? The script: local Player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed + 1 Player.leaderstats.OOF.Value = Player.leaderstats.OOF.Value + 1 game.Workspace.Sound:Play() script.Parent:Destroy() end)

0
on click walkspeed = walkspeed +1 User#21908 42 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

I think you missed out this line of code

script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed + 1

So this finishing code should be

local Player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed + 1 Player.leaderstats.OOF.Value = Player.leaderstats.OOF.Value + 1 game.Workspace.Sound:Play() script.Parent:Destroy() end)

Hope this helps..

0
XviperIink Thank you for helping ! It worked ! brodski40 8 — 6y
0
Great! Accept my answer :) XviperIink 428 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

While xviperlink's code works, it can be cleaned up a little. I presume that script.Parent.Parent.Parent.Parent is the player, so just use that variable, also,

PLEASE INDENT YOUR CODE!

So a cleaner local script might look something like this:

local char = game.Players.LocalPlayer.Character
local hum = char:FindFirstChild(""Humanoid")
script.Parent.MouseButton1Click:Connect(function()
    if hum then--check if the humanoid exists
        hum.WalkSpeed = hum.WalkSpeed + 1
    end
end)

Answer this question