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

My walk GUI isn't working?

How come this doesn't work (ROBLOX says the first line is inccorrect?)

scriptl = game.StarterGui.ScreenGui.Walk.script

function Walking() scriptl.Parent.Parent.Parent.Parent.Character.Humanoid.Walkspeed = 16 end

scriptl.Parent.MouseButton1:connect(Walking)

1 answer

✓ Accepted answer

There are many errors in this script, but it's nothing we can't fix. First of all, the first line is incorrect because of how you define scriptl. PlayerGui is in the Player, which is in Players, which is in the game. This is how it should look:

Game
	Players
		club101coolguy
			PlayerGui
				ScreenGui
					Walk
						Script

scriptl = game.Players.club101coolguy.PlayerGui.ScreenGui.Walk.Script

Of course this script will only work for one player (you). Using LocalPlayer can solve this issue by making the GUI functional for everyone and simplifying the next line.

What is LocalPlayer? LocalPlayer basically means "you, the player". It can only be used in LocalScripts and is used to identify who the player is.

scriptl = game.Players.LocalPlayer.PlayerGui.ScreenGui.Walk.Script

This also shortens the next line, turning that long chain of Parents into:

game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16

Don't forget, it's spelled "WalkSpeed". Finally, the last line should say this:

scriptl.Parent.MouseButton1Click:connect(Walking)

EDIT: Don't use StarterGui, use PlayerGui. The button is in PlayerGui. If it was in StarterGui, the button wouldn't show up on the player's screen. In fact, defining scriptl is entirely unnecessary. Put the script in the button and try this instead:

function Walking()
	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 end
script.Parent.MouseButton1:connect(Walking)

3 comments

0

Thx for the help, but for some reason the output is saying "StarterGui is not a Valid member of Player." Any help on this?

0

Oops, I made a mistake. Let me fix that

0

Thx!

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