so, what i'm trying to do is make a fun lil tag game but i can't figure out how to make a gui that says (it) over their head and when u touch another player it moves to their head, for better understanding
you got a (it) text over your head, i see a player, ima go over and tag him.. i tag him, the text goes from my head to his head.
Assuming the gui is in a player's character-
01 | local Players = game:GetService( "Players" ) |
02 | local Gui = script.Parent |
03 | local GuiOwner = Gui.Parent |
04 |
05 | local Torso = GuiOwner.Torso |
06 |
07 | wait(. 5 ) -- Waits half a second so that the person can't tag back instantly. |
08 |
09 | Torso.Touched:Connect( function (hit) -- Happens when the torso gets touched. |
10 | if hit.Parent:FindFirstChild( "Humanoid" ) then -- Checks if what the player touched has a humanoid. |
11 | if Players:FindFirstChild(hit.Parent.Name) then -- Checks if it's a player. |
12 | local NewGui = Gui:Clone() -- Clones the tag. |
13 | NewGui.Parent = hit.Parent -- Parents the new tag to the touched player. |
14 | NewGui.Adornee = hit.Parent.Head -- Puts the tag above the touched player's head. |
15 | Gui:Destroy() -- Destroys the tag above the old player. |
16 | end |
17 | end |
18 | end ) |
when i join game, the gui doesn't appear over my head, trying to get it where who ever joins game first is it lol.
01 | local rs = game:GetService( "ReplicatedStorage" ) |
02 | local Players = game:GetService( "Players" ) |
03 | local Tagger = false |
04 | local Gui = rs:WaitForChild( "Gui" ) -- Or where ever you have the gui |
05 |
06 | Players.PlayerAdded:Connect( function (plr) |
07 | if Tagger = = false then |
08 | Tagger = true -- So it only happens for the first player |
09 | repeat |
10 | wait() |
11 | until plr.Character.Head -- Waits until the player's character is spawned and the head is found. |
12 | Gui.Parent = plr.Character |
13 | Gui.Adornee = plr.Character.Head |
14 | end |
15 | end ) |
Haven't tested this out but it should work.