I have made this script which will show an image above the heads of players in the game. - There are no problems with this aspect
An error occurs when a player (does not matter whether they have the image or not) leaves the game and I'm not sure why this is.
The error:
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
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)
Can anyone tell me why this error is being spit out so I can fix it? Thank you
