RESOLVED BUT KEEPING UP IN CASE SOMEONE WHO NEEDS HELP WITH THIS LATER ON STUMBLES OVER THIS
The issue with this was that I was trying to access other players' PlayerGuis from a local script, which is in fact, impossible. What you need to do is use remoteevents. Cheers!
Hi all, I'm trying to clone and parent a billboard gui to a player's PlayerGui so that only they can see it. However I keep getting the following error at every point in the following script where PlayerGui is called: >PlayerGui is not a valid member of Player
How can I fix this? :/
Note that this is button activated, and in testing, I did not press the button until at least 15 seconds after the player spawned, and in another script, the PlayerGui is being called with no issues
Any help would be greatly appreciated. Thanks!
This is the code:
--[[ Created By: Cubes4Life ]]-- --// Initialization wait(2) --// Variable Storage local player = game.Players.LocalPlayer local currHost = game.Lighting.CurrentHost local currAssis = game.Lighting.CurrentAssistant local PTSEnabled = script.Parent.PTSBool _G.AFKEnabled = false local debounce = false local Click = Instance.new('Sound', player) Click.Name = 'Click' Click.SoundId = 'http://www.roblox.com/asset/?id=156286438' --// Script Logic function Implement(status) script.Parent[status].Check.Visible = true if game.Players:FindFirstChild(currHost.Value) then if game.Players[currHost.Value]:WaitForChild('PlayerGui'):FindFirstChild(player.Name) then game.Players[currHost.Value]:WaitForChild('PlayerGui'):FindFirstChild(player.Name):Destroy() end game.ReplicatedStorage.HostBillboardNotif:Clone().Parent = game.Players[currHost.Value].PlayerGui game.Players[currHost.Value].PlayerGui.HostBillboardNotif.TextButton.Text = status game.Players[currHost.Value].PlayerGui.HostBillboardNotif.Name = player.Name end if game.Players:FindFirstChild(currAssis.Value) then if game.Players[currAssis.Value].PlayerGui:FindFirstChild(player.Name) then game.Players[currAssis.Value].PlayerGui:FindFirstChild(player.Name):Destroy() end game.ReplicatedStorage.HostBillboardNotif:Clone().Parent = game.Players[currAssis.Value].PlayerGui game.Players[currAssis.Value].PlayerGui.HostBillboardNotif.TextButton.Text = status game.Players[currAssis.Value].PlayerGui.HostBillboardNotif.Name = player.Name end end function Destroy(status, counter) script.Parent[status].Check.Visible = false if game.Players:FindFirstChild(currHost.Value) then game.Players[currHost.Value].PlayerGui:FindFirstChild(player.Name):Destroy() end if game.Players:FindFirstChild(currAssis.Value) then game.Players[currAssis.Value].PlayerGui:FindFirstChild(player.Name):Destroy() end end script.Parent.PTS.MouseButton1Down:connect(function() if PTSEnabled.Value == false then PTSEnabled.Value = true _G.AFKEnabled = false Implement('PTS') else PTSEnabled.Value = false Destroy('AFK') end end) script.Parent.AFK.MouseButton1Down:connect(function() if _G.AFKEnabled == false then _G.AFKEnabled = true PTSEnabled.Value = false Implement('AFK') else _G.AFKEnabled = false Destroy('PTS') end end)