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!
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