Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to set frame.visible = false for all players?

Asked by 4 years ago

This is my current script to destroy the gui after a player clicks on it: (LocalScript- inside the Gui which I want to disappear after I click)

script.Parent.MouseButton1Click:Connect(function()
    if player.leaderstats.Cash.Value >= 60 then
        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 60
        script.Parent.Parent:Destroy()
        MediterraneanAvenue.Parent = game.Players.LocalPlayer.Backpack

however, I want the gui gets destroyed only for the player who clicks it. I want the gui to be destroyed from all players, or set enabled = false for that sake.

How can I do this? With what code? can you please help me?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I'm kind of confused by your question, I'm assuming your question is that all players will have the ScreenGui and when the button inside the ScreenGui is clicked it will destroy all ScreenGuis for all players in the game? If so, this is very simple to do with RemoteEvents.

First of all, put a RemoteEvent inside of ReplicatedStorage.

Second, place a Local Script inside of the button and put the following code inside of it:

script.Parent.MouseButton1Click:Connect(function()

    if player.leaderstats.Cash.Value >= 60 then
        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 60
        game.ReplicatedStorage.RemoteEvent:FireServer() 

        MediterraneanAvenue.Parent = game.Players.LocalPlayer.Backpack
    end
end)

Next you will need to put a Server Script inside of ServerScriptService and then put the following code inside of it:

local Players = game:GetService("Players")

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()

    for i,v in pairs(Players:GetChildren()) do
        local PutGuiNameHere = v:FindFirstChild("PlayerGui"):WaitForChild("PutGuiNameHere") -- Replace "PutGuiNameHere" with the Gui name that you want to destroy.
        PutGuiNameHere:Destroy()

    end
end)

Again, It was hard to understand what you were asking for and hopefully this is the answer you were looking for.

If this is not what you were asking for, just put a comment below and I'll try to help you.

0
my gui is located over here: game.Players.LocalPlayer.PlayerGui.MediterraneanAvenue.StartUp QuantumxGeneral 25 — 4y
0
is it okay if I just put local ScreenGui = game.Players.LocalPlayer.PlayerGui.MediterraneanAvenue.StartUp ? QuantumxGeneral 25 — 4y
0
The Local ScreenGui is the Gui that is being destroyed. Is MediterraneanAvenue the Gui you want to destroy? If so, then yes, replace the Local ScreenGui to Local ScreenGui = v:FindFirstChild("PlayerGui"):WaitForChild("MediterraneanAvenue") Also I noticed that in your post you set the parent of MediterraneanAvenue to the player's Backpack, is it supposed to be in the backpack or the PlayerGui?  xInfinityBear 1777 — 4y
0
no my gui is a frame named startup under mediterraneanAvenue. MediterraneanAvenue has other frames I dont want to delete QuantumxGeneral 25 — 4y
View all comments (7 more)
0
local ScreenGui = v:FindFirstChild("PlayerGui"):WaitForChild("ScreenGui") <-- Replace ScreenGui with the Gui you want to destroy for all players xInfinityBear 1777 — 4y
0
I apologise if I don't quite understand your question. So is MediterraneanAvenue in the Gui that's being destroyed? Is that why you're changing it's parent? xInfinityBear 1777 — 4y
0
no, startup is a frame inside Mediterranean Avenue. Start up is being destroyed QuantumxGeneral 25 — 4y
0
no, startup is a frame inside Mediterranean Avenue. Start up is being destroyed QuantumxGeneral 25 — 4y
0
local ScreenGui = v:FindFirstChild("PlayerGui"):WaitForChild("MediterraneanAvenue"):WaitForChild("StartUp") --is this correct? QuantumxGeneral 25 — 4y
0
MediterraneanAvenue is a screen gui. The mediterraneanAvenue I changed parents for was actually a tool, so dont confuse with it. Pleasseeeee help me! QuantumxGeneral 25 — 4y
0
Actually I ot it bro QuantumxGeneral 25 — 4y
Ad

Answer this question