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

How to make GUI appear above player head?

Asked by 4 years ago

Hey again. Guy that is making a baseball game, and I ran into another problem where I just can't seem to get this GUI to appear visible above my head. Not sure whats wrong, but I think it has to do with WaitForChild? Or maybe I'm wrong.

local Player = game:GetService("Players").LocalPlayer
local Base = script.Parent
local GUI = game:GetService("ServerStorage"):WaitForChild("SafeGUI")
local Debris = game:GetService("Debris")

Base.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("BillboardGui", true) then
        local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
        if not Player then
            return
        end      
        local SafeSign = GUI:Clone()
        SafeSign.Parent = (Player.Name).Head
        SafeSign.Enabled = true
        SafeSign.ImageLabel.Visible = true
        SafeSign.Adornee = (Player.Name).Head
        Debris:AddItem(SafeSign, 3)
    end
end)



Base.TouchEnded:Connect(function(hit)
    for i = 1, #Base:GetTouchingParts() do
        if Base:GetTouchingParts()[i].Parent and Base:GetTouchingParts()[i].Parent == hit.Parent then
            return 
        end
    end

    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
        if hit.Parent.Head:FindFirstChild("BillboardGui") then
            Debris:AddItem(hit.Parent.Head:FindFirstChild("BillboardGui"))
        end
    end
end)
0
You do know that LocalPlayer ONLY works in local scripts? And local scripts don't work in workspace so... You would need to make a remote event. PrismaticFruits 842 — 4y

1 answer

Log in to vote
0
Answered by
notfenv 171
4 years ago

Change line 13 and 16 to "Player.Character:WaitForChild("Head")

Ad

Answer this question