I've been trying to creating an overhead gui without using anything associated with groups or names, just user ids but for some reason this script is not working and no errors are being displayed. Here's the script:
--Variables-- BillboardGui = script.Parent.BillboardGui --Settings-- Visitors = {"83997127", "3242545", "3423455"} --Put user ids here that are visitors EventManagement = {"TESTID", "3242545", "3423455"} --Put the user ids here that are managing the event MaxOverheadDistance = 25 --Sets how far you can see the overhead gui above players --Core-- Players.PlayerAdded:Connect(function(players) for i, v in pairs(Visitors) do if (players.UserId == v) then BillboardGui:Clone(); BillboardGui.Player.Text = player.Name; BillboardGui.Position.Text = "Honoured Visitor"; BillboardGui.MaxDistance = MaxOverheadDistance; BillboardGui.Parent = game.Workspace:WaitForChild(players.UserId) end end end --
Any help will be much appreciated!
--Main Variables-- BillboardGui = script.Parent.BillboardGui --Services-- Players = game:GetService('Players') --Settings-- Visitors = {83997127, 3242545, 3423455} EventManagement = {3242545, 3423455} MaxOverheadDistance = 25 --Core-- function checkUserId(Player) for _,v in pairs(Visitors) do if type(v) == "number" and v == Player.UserId then return 'Honoured Visitor' end end for _,v in pairs(EventManagement) do if type(v) == "number" and v == Player.UserId then return 'Event Management' end end return nil end Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local BG = BillboardGui:Clone() BG.Parent = Character:WaitForChild('Head') BG.Player.Text = Player.Name BG.MaxDistance = MaxOverheadDistance; if checkUserId(Player) ~= nil then BG.Position.Text = checkUserId(Player) end end) end)
I am not entirely sure if this will work, but let me know if any errors come up.
Use LocalScript
local players = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() local BillboardGui = script.Parent.BillboardGui local Visitors = {83997127,3242545,3423455} -- Don't add "" when u use Numbers local EventManagement = {3242545, 3423455} -- Don't add "" when u use Numbers local MaxOverheadDistance = 25 wait() for i, v in pairs(Visitors) do if players.UserId == v then BillboardGui:Clone().Parent = workspace:FindFirstChild(players.Name).Head BillboardGui.Player.Text = players.Name BillboardGui.Position.Text = "Honoured Visitor" BillboardGui.MaxDistance = MaxOverheadDistance end end
Consider changing the beginnings of the constants put 'local' into it.
--Variables-- local BillboardGui = script.Parent.BillboardGui
--Settings-- local Visitors = {"83997127", "3242545", "3423455"} --Put user ids here that are visitors local EventManagement = {"TESTID", "3242545", "3423455"} --Put the user ids here that are managing the event local MaxOverheadDistance = 25 --Sets how far you can see the overhead gui above players
--Core-- game.Players.PlayerAdded:Connect(function(players) for i, v in pairs(Visitors) do if (players.UserId == v) then BillboardGui:Clone(); BillboardGui.Player.Text = player.Name; BillboardGui.Position.Text = "Honoured Visitor"; BillboardGui.MaxDistance = MaxOverheadDistance; BillboardGui.Parent = game.Workspace:WaitForChild(players.UserId) end end