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 5 years ago
Edited 5 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 — 5y
0
wouldn't the gui go into lighting or something? but the scripting part. A1exTatum 57 — 5y
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 — 5y
0
Use a BillboardGui and parent it to the player's character. LawlR 182 — 5y
0
so like script.Parent = game.Player.LocalPlayer.Character.Head? A1exTatum 57 — 5y

1 answer

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

Assuming the gui is in a player's character-

local Players = game:GetService("Players")
local Gui = script.Parent
local GuiOwner = Gui.Parent

local Torso = GuiOwner.Torso

wait(.5) -- Waits half a second so that the person can't tag back instantly.

Torso.Touched:Connect(function(hit) -- Happens when the torso gets touched.
    if hit.Parent:FindFirstChild("Humanoid") then -- Checks if what the player touched has a humanoid.
        if Players:FindFirstChild(hit.Parent.Name) then -- Checks if it's a player.
            local NewGui = Gui:Clone() -- Clones the tag.
            NewGui.Parent = hit.Parent -- Parents the new tag to the touched player.
            NewGui.Adornee = hit.Parent.Head -- Puts the tag above the touched player's head.
            Gui:Destroy() -- Destroys the tag above the old player.
        end
    end
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.

local rs = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Tagger = false
local Gui = rs:WaitForChild("Gui") -- Or where ever you have the gui

Players.PlayerAdded:Connect(function(plr)
    if Tagger == false then
        Tagger = true -- So it only happens for the first player
        repeat
            wait()
        until plr.Character.Head -- Waits until the player's character is spawned and the head is found.
        Gui.Parent = plr.Character
        Gui.Adornee = plr.Character.Head
    end
end)

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 — 5y
0
Edited my answer. LawlR 182 — 5y
0
line 11 has an error, ServerScriptService.Script:14: attempt to index field 'Character' (a nil value) A1exTatum 57 — 5y
0
Okay, try changing it to just plr.Character. LawlR 182 — 5y
View all comments (7 more)
0
Torso is not a valid member of DataModel (assuming its from the top script) another error A1exTatum 57 — 5y
0
Did the player die? Are you using R15 or R6? LawlR 182 — 5y
0
using r15, should i switch to r6? A1exTatum 57 — 5y
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 — 5y
0
? A1exTatum 57 — 5y
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 — 5y
0
alr, i'll see if anyone knows about the error. thanks for the help. A1exTatum 57 — 5y
Ad

Answer this question