I want to change the visibility of a frame after a remote event is fired.
Even though it prints “true” for gui.Visible, it never shows on the screen, and is also false when going to Players > PlayerName > And into the gui.
local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:WaitForChild("PublicOrPrivate").Frame
game.ReplicatedStorage.PublicOrPrivate.PickEvent.OnClientEvent:Connect(function()
gui.Visible = true
for _, choice in pairs(gui:GetChildren()) do
choice.MouseButton1Click:Connect(function()
if choice.Name == "Public" then
game.ReplicatedStorage.PublicOrPrivate.ReturnEvent:FireServer("Public")
else
game.ReplicatedStorage.PublicOrPrivate.ReturnEvent:FireServer("Private")
end
end)
gui.Visible = false
end
end)
You have something in the Frame besides buttons, if so, write a condition.
Or the removeEvent call has errors and the script is interrupted.
local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:WaitForChild("PublicOrPrivate").Frame
game.ReplicatedStorage.PublicOrPrivate.PickEvent.OnClientEvent:Connect(function()
gui.Visible = true
for _, choice in pairs(gui:GetChildren()) do
if choice:IsA("TextButton") then
choice.MouseButton1Click:Connect(function()
if choice.Name == "Public" then
game.ReplicatedStorage.PublicOrPrivate.ReturnEvent:FireServer("Public")
else
game.ReplicatedStorage.PublicOrPrivate.ReturnEvent:FireServer("Private")
end
end)
end
gui.Visible = false
end
end)
for _, choice in pairs(gui:GetChildren()) do
choice.MouseButton1Click:Connect(function()
if choice.Name == "Public" then
game.ReplicatedStorage.PublicOrPrivate.ReturnEvent:FireServer("Public")
else
game.ReplicatedStorage.PublicOrPrivate.ReturnEvent:FireServer("Private")
end
gui.Visible = false
end)
end