Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to Increase walkspeed per Click on GUI?

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)

1 comment

0

on click walkspeed = walkspeed +1

2 answers

✓ Accepted answer

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..

2 comments

0

XviperIink Thank you for helping ! It worked !

0

Great! Accept my answer :)

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.