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

Simple Run/Walk GUI giving error at colon?

Asked by 6 years ago

I made a simple run and walk GUI but it isn't working and it's giving me an error at this colon: MouseButton1Click:Connect

This is the error: Players.xKhaIeesi.PlayerGui.WalkRunGUI.Frame.Run.RunScript:1: function arguments expected near ':'

Here's the run script:

script.Parent:MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 64
end)

and here's the walk script:

script.Parent:MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end)

Thanks

2 answers

Log in to vote
0
Answered by
Vulkarin 581 Moderation Voter
6 years ago

If I were you I would make this connected to a remote event instead because this script wouldn't work in game with filter enabled but here's the working version anyway

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end)
1
Actually, LocalScripts can change the Humanoid WalkSpeed even with FilteringEnabled. Your answer is correct though, you should've just given a little explanation on what you did to fix it. Mayk728 855 — 6y
0
Ah you're right wasn't thinking about all those silly exploiters...as for not explaining sorry I was a bit rushed Vulkarin 581 — 6y
Ad
Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago

The problem is that you indexed the MouseButton1Click event as if you were invoking a method. You're supposed to use periods . for events, because colons : are the syntax for calling functions.

Moreover;

script.Parent.MouseButton1Click:Connect(function()
    --code
end)

Answer this question