I have a script which will show an Image above the heads of players in a certain group and whenever somebody leaves the game, this error will appear:
Player:IsInGroup error: Player not in datamodel Stack Begin Script 'ServerScriptService.Overhead GUI', Line 5 - global onPlayerRespawned Script 'ServerScriptService.Overhead GUI', Line 26 Stack End
Here is the script in ServerScriptService:
local groupID = GROUPIDHERE
function onPlayerRespawned(newPlayer)
wait(1)
if newPlayer:IsInGroup(groupID) then
local gui=Instance.new("BillboardGui")
gui.Parent=newPlayer.Character.Head
gui.Adornee=newPlayer.Character.Head
gui.Size=UDim2.new(3,0,3,0)
gui.StudsOffset=Vector3.new(0.5,2,0)
local text=Instance.new("ImageLabel")
text.Image = "rbxgameasset://Images/Photo"
text.Size=UDim2.new(1,0,1,0)
text.Position=UDim2.new(-0.225,0,-0.35,-45)
text.BackgroundTransparency = 1
text.Parent=gui
print(newPlayer.Name.. " is a member of group")
end
end
game.Players.PlayerAdded:Connect(onPlayerRespawned)
function onPlayerEntered(newPlayer)
newPlayer.Changed:Connect(function (property)
if (property == "Character") then
onPlayerRespawned(newPlayer)
print("Reloading " ..newPlayer.Name.. "'s GUI")
end
end)
end
game.Players.PlayerAdded:Connect(onPlayerEntered)
How can I solve this error? Thanks

1 comment
It's quite clear that you didn't script this. https://scriptinghelpers.org/help/how-post-good-questions-answers