Hey Guys! I have been working on an overhead script with icons and I have just recently noticed that when a player resets, their overhead gui dissappears. I have tried all of the possible solutions that I could think of which was putting it in character scripts & adjusting the script. I just cannot possible get it to work, any help would be much appreciated.
So the first thing here:
character:WaitForChild(“Humanoid”) – Ensure the character is fully loaded
createOverhead(player, character)
I would put a task.wait here:
character:WaitForChild(“Humanoid”) – Ensure the character is fully loaded
task.wait(0.5)
createOverhead(player, character)
Don’t put it waaay too small (the wait) otherwise, it will just don’t work, so make sure to put that and see if it works, and if it don’t works, i’m gonna try to come up with another solution
And why are you doing 1 check and 1 thing? you don’t need to do the check, or you just doing that to safety? i actually would remove the “if player.characteradded”, try doing that
Hey, thanks for responding. I have tried both methods & removed that bit (added that just to see if it would work but it didn’t). It spawns above my head when I load in, but it disappears after I reset unsure what else we could do.
The code inside of this function you’ve made only runs when the player joins the game, not when their character is added.
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
createOverhead(player, character)
end)
Change it to this:
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character
if (character) then -- If the character happens to exist by the time this line is reached(doubtful)
createOverhead(player, character)
end
player.CharacterAdded:Connect(function(character)
createOverhead(player, character)
end)
end)
This’ll call the function each time the character spawns.
Also, change this
overhead.Parent = character.Head
if player.CharacterAdded then
if overhead.Parent ~= player.Character:WaitForChild("Head") then
overhead.Parent = player.Character:WaitForChild("Head")
end
end
to just this
overhead.Parent = character:WaitForChild("Head")
Thank you, this was my solution. I appreciate all of your help
Glad you got it working, now go on, have fun on your game! Chase your dreams!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.