Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i make a gui appear to my head then when i touch another player, it moves to his head?

Asked by 6 years ago
Edited 6 years ago

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.

0
Do you need help with making the gui or the script that gives the gui to another player? or both LawlR 182 — 6y
0
wouldn't the gui go into lighting or something? but the scripting part. A1exTatum 57 — 6y
0
For the script, when the player with the gui touches another player (use .Touched), change the gui's adornee to the other player's head. LawlR 182 — 6y
0
Use a BillboardGui and parent it to the player's character. LawlR 182 — 6y
0
so like script.Parent = game.Player.LocalPlayer.Character.Head? A1exTatum 57 — 6y

1 answer

Log in to vote
0
Answered by
LawlR 182
6 years ago
Edited 6 years ago

Assuming the gui is in a player's character-

01local Players = game:GetService("Players")
02local Gui = script.Parent
03local GuiOwner = Gui.Parent
04 
05local Torso = GuiOwner.Torso
06 
07wait(.5) -- Waits half a second so that the person can't tag back instantly.
08 
09Torso.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
18end)

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.

01local rs = game:GetService("ReplicatedStorage")
02local Players = game:GetService("Players")
03local Tagger = false
04local Gui = rs:WaitForChild("Gui") -- Or where ever you have the gui
05 
06Players.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
15end)

Haven't tested this out but it should work.

0
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. A1exTatum 57 — 6y
0
Edited my answer. LawlR 182 — 6y
0
line 11 has an error, ServerScriptService.Script:14: attempt to index field 'Character' (a nil value) A1exTatum 57 — 6y
0
Okay, try changing it to just plr.Character. LawlR 182 — 6y
View all comments (7 more)
0
Torso is not a valid member of DataModel (assuming its from the top script) another error A1exTatum 57 — 6y
0
Did the player die? Are you using R15 or R6? LawlR 182 — 6y
0
using r15, should i switch to r6? A1exTatum 57 — 6y
0
still gives me the error when i test the game. and no, the player didn't die, it just randomly showed up A1exTatum 57 — 6y
0
? A1exTatum 57 — 6y
0
If you're using R15, change Torso to UpperTorso or LowerTorso. If that doesn't fix it then I'm not sure. LawlR 182 — 6y
0
alr, i'll see if anyone knows about the error. thanks for the help. A1exTatum 57 — 6y
Ad

Answer this question