#MainGui is not a valid member of PlayerGui "Players.<Player>.PlayerGui"
1 messages · Page 1 of 1 (latest)
could be getting called too early. try waitforchild
How would I use that? Sry im new to script
Is it a script or local script?
i think but like that the error happens because the StaterGui gets copied into PlayerGui only on the client side so like if the script is running on the server it won’t see the MainGui in PlayerGui idk if im correct
im most likely wrong lol
this is not correct
send the relevant part of the script
local player = game.Players.LocalPlayer
player.CameraMaxZoomDistance = 50
leaveGuiEvent.OnClientEvent:Connect(function()
player.PlayerGui.MainGui.leaveButton.Visible = true
end)
player.PlayerGui.MainGui.leaveButton.MouseButton1Down:connect(function()
leaveGuiEvent:FireServer()
player.PlayerGui.MainGui.leaveButton.Visible = false
end)``` line 9
player.PlayerGui.MainGui.leaveButton.MouseButton1Down:connect(function()
Like this player.WaitForChild.MainGui.leaveButton.MouseButton1Down:connect(function()?
oh i see the issue
local leaveGuiEvent = game.ReplicatedStorage.LeaveGuiEvent
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
player.CameraMaxZoomDistance = 50
leaveGuiEvent.OnClientEvent:Connect(function()
player.PlayerGui.MainGui.leaveButton.Visible = true
end)
playerGui:WaitForChild("MainGui").leaveButton.MouseButton1Down:connect(function()
leaveGuiEvent:FireServer()
player.PlayerGui.MainGui.leaveButton.Visible = false
end)
What was the issue? Sorry im trying to learn
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
player.CameraMaxZoomDistance = 50
leaveGuiEvent.OnClientEvent:Connect(function()
player.PlayerGui.MainGui.leaveButton.Visible = true
end)
playerGui:WaitForChild("MainGui").leaveButton.MouseButton1Down:connect(function()
leaveGuiEvent:FireServer()
player.PlayerGui.MainGui.leaveButton.Visible = false
end)``` Hey this is my current script and Im getting this error `Script 'Players.<Player>.PlayerScripts.LeaveButtonScript', Line 9`
@timid drift
Im confused because there is nothing on line 9
so basically the script is called at runtime, and it's sometimes a race condition as to whether startergui has been duplicated by the time the script runs
send the full error
Nvn it's working now