I'm using IsInGroup() for my game, and it isn't exactly working. Can someone help me?
game.Players.PlayerAdded:Connect(function() local id = 5150581 if game.Players.LocalPlayer:IsInGroup(id) then game.Lighting:WaitForChild("Yoghurt").Parent = game.Players.LocalPlayer.Backpack end end)
PlayerAdded
will not fire for the client that joins the game, but all other clients that join after.
You should be doing this in a server script instead. Here's some sample code:
local Players = game:GetService("Players") local id = 5150581 Players.PlayerAdded:Connect(function(player) -- server will get every player that joins if player:IsInGroup(id) then local tool = game.Lighting:WaitForChild("Yoghurt") -- i recommend you put these in ReplicatedStorage or ServerStorage, and NOT Lighting. Lighting is not meant for storage. player.CharacterAdded:Connect(function(char) -- gives it to them every character spawn tool:Clone().Parent = player.Backpack end) end end)
Sometimes, while Roblox runs slow the function doesn't process the variable id try just inputting the ID, if neither works then ensure HTTP Requests & API Services are enabled and if still nothing works just wait it out a bit.
local id = 5150581--we can keep this variable outside since it wont update anyway game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function()--wait for the character to load so it knows who to check on, this will update every time a new character gets added instead of a new player if player:IsInGroup(id) then --and here u check if they are in the group since this will get checked after the character gets added game.ServerStorage:WaitForChild("Yoghurt"):Clone().Parent = player:WaitForChild("Backpack") --if u dont clone it then it will only work once because ur not creating a duplicate, also the backpack gets deleted every time the player dies and recreated so wait for the backpack to be created too end end) end)