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

How do I fix my group script that when you join, it slow you down?

Asked by 8 years ago

So I have a script that when you join the game, it slow you down if you are in a certain group..

But it dosent seems like its working..

Heres the (Local) script :

local p = game.Players.LocalPlayer

if game.Players.LocalPlayer:IsInGroup(1123543) then
    game.Workspace.p.Humanoid.WalkSpeed.Value = 1
    script.Parent:Destroy()

else
    script.Parent.Frame.Visible = true
    script.Parent.Frame.TextButton.MouseButton1Click:connect(function()
        script.Parent:Destroy()
    end)
end

I think It's not working because the "p" is not at the good place or something like this..

**I will also give some Reputation point if you can help me.. **

Thanks!

0
Well, hopefully you' give rep to someone for helping you. alphawolvess 1784 — 8y
0
Well there is some people that doesn't do that even if you answer to their question.. starchip12 6 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Overall, your script appears fine. However, you'd not using a variable correctly. You made the variable p equal to the Player. So, you should make line 3 become

if p:IsInGroup(1123543) then

This is faster to type so you can code quicker, no point in not using your variable! Next you put p as if it was a member of Workspace. This is false, p is a Player instance so this will just 'confuse' the script. You would want to do this to change their walkspeed:

p.Character:WaitForChild("Humanoid").WalkSpeed = 1 -- Pretty slow speed, btw.

Character is a property in Player that gives you either nil or their Character if it exists. Now, WaitForChild will make sure we don't attempt to change Humanoid if it doesn't exist. There is also a problem now that could make this script attempt to find the player before it's made. To do this, I like to add repeat wait() until p.Character which will loop until Character exists. This goes at the start of the scripting giving us the whole script bellow. Also, Value is not needed, WalkSpeed is the value. Value is only for things like IntValue, BoolValue, etc!

local p = game.Players.LocalPlayer
repeat wait() until p.Character

if p:IsInGroup(1123543) then
    p.Character:WaitForChild("Humanoid").WalkSpeed = 1
    script.Parent:Destroy()
else
    script.Parent.Frame.Visible = true
    script.Parent.Frame.TextButton.MouseButton1Click:connect(function()
        script.Parent:Destroy()
    end)
end

Accept this answer if it helps! If you have questions/problem then comment bellow

1
AMAZING Answer! Thanks a lot fam :D This helped me a lot! The explications are clear and easy to understand! Awesome! Again, thanks a lot xP starchip12 6 — 8y
0
No problem alphawolvess 1784 — 8y
Ad

Answer this question