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

My walk GUI isn't working?

Asked by
Vid_eo 126
8 years ago

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

Log in to vote
1
Answered by 8 years ago

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)
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? Vid_eo 126 — 8y
0
Oops, I made a mistake. Let me fix that IcyArticunoX 355 — 8y
0
Thx! Vid_eo 126 — 8y
Ad

Answer this question