Ad
Log in to vote
1

Simple Run/Walk GUI giving error at colon?

Asked by 11 months 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 548 Moderation Voter
11 months 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. iiMayk 437 — 11mo
0
Ah you're right wasn't thinking about all those silly exploiters...as for not explaining sorry I was a bit rushed Vulkarin 548 — 11mo
Ad
Log in to vote
0
Answered by
Goulstem 7925 Badge of Merit Moderation Voter Administrator Community Moderator
11 months ago
Edited 11 months 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