So this first script is a LOCAL SCRIPT This LOCAL SCRIPT is inside a TEXTBUTTON where only certain people can see.
1 | script.Parent.MouseButton 1 Click:Connect( function (plr) |
2 | game.ReplicatedStorage.DisableBalls:FireServer(game.Players:GetPlayers()) |
3 | 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?
1 | game.ReplicatedStorage.DisableBalls.OnServerEvent:Connect( function (player, localplayer) |
2 | for _,v in pairs (localplayer) do |
3 | v.PlayerGui:WaitForChild( "ScreenGui" ).Spawn.TextButton.Text = "Disabled" |
4 | v.PlayerGui.ScreenGui.Spawn.TextButton.LocalScript.Disabled = true |
5 | end |
6 | 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
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | game.ReplicatedStorage.RemoteEvent:FireServer() |
3 | end ) |
server script
1 | game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect( function () |
2 | game.ReplicatedStorage.RemoteEvent 2 :FireAllClients() |
3 | end ) |
local script for removing gui
1 | local players = game.Players:GetPlayers() |
2 |
3 | game.ReplicatedStorage.RemoteEvent 2. OnClientEvent:Connect( function () |
4 | for i,v in pairs (players) do |
5 | v.PlayerGui.Thing:Destroy() |
6 | end |
7 | 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
1 | for i,plr in next , game:GetService( "Players" ):GetPlayers() do |
2 | local gui = plr:FindFirstChild( "PlayerGui" ); |
3 | if (gui) then |
4 | --code here |
5 | print (plr.Name.. " gui exists!" ); |
6 | end |
7 | end |
Hope this helps!