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)

1 comment
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.