So this first script is a LOCAL SCRIPT This LOCAL SCRIPT is inside a TEXTBUTTON where only certain people can see.
script.Parent.MouseButton1Click:Connect(function(plr) game.ReplicatedStorage.DisableBalls:FireServer(game.Players:GetPlayers()) end)
The other script is a SERVER SCRIPT And this is inside SERVER SCRIPT SERVICE This is wrong i know that but I just want to know how do i access everyones playergui inside a server script?
game.ReplicatedStorage.DisableBalls.OnServerEvent:Connect(function(player, localplayer) for _,v in pairs(localplayer) do v.PlayerGui:WaitForChild("ScreenGui").Spawn.TextButton.Text = "Disabled" v.PlayerGui.ScreenGui.Spawn.TextButton.LocalScript.Disabled = true end end)
This was just me having a go at it
to remove a gui on all clients, you could make a local script that fires to a server script which fires to a local script to remove the gui like this:
local script for textbutton
script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer() end)
server script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() game.ReplicatedStorage.RemoteEvent2:FireAllClients() end)
local script for removing gui
local players = game.Players:GetPlayers() game.ReplicatedStorage.RemoteEvent2.OnClientEvent:Connect(function() for i,v in pairs(players) do v.PlayerGui.Thing:Destroy() end end)
i keep on thinking i dont need to use the for i,v in pairs() do
, bc i used :FireAllClients()
, but it worked for him on discord so idc lol
for i,plr in next, game:GetService("Players"):GetPlayers() do local gui=plr:FindFirstChild("PlayerGui"); if(gui) then --code here print(plr.Name.." gui exists!"); end end
Hope this helps!