Disable Backpack for normal scripts

How do I disable the player’s back with a normal script? This is for a revive system. There’s one that works only for local scripts and I’ve tried it for normal scripts and it doesn’t work.

local StarterGui = game:GetService("StarterGui")
				
				StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)  -- disable inventory

Have a server script fire a particular client through a RemoteEvent instance and then execute that same line of code in a local script instead. Here’s an example which disables a player’s backpack when they first join the game, after 5 seconds have elapsed the player’s backpack is enabled.

--SERVER

local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated.RemoteEvent

Players.PlayerAdded:Connect(function(Player)
	Remote:FireClient(Player, false)
	task.wait(5)
	Remote:FireClient(Player, true)
end)
--LOCAL

local StarterGui = game:GetService("StarterGui")
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated:WaitForChild("RemoteEvent")

Remote.OnClientEvent:Connect(function(Toggle)
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, Toggle)
end)

The server script goes inside the “ServerScriptService” folder, the local script goes inside the “StarterPlayerScripts” folder and finally a RemoteEvent instance named “RemoteEvent” goes inside the “ReplicatedStorage” directory.

This works and you can test it by putting a tool into the “StarterPack” folder.

My revive script is also inside of ServerScriptService, will that still work?

You can only set Core Gui through a local script because it is something based on the local side for each player. Thus you would need to pass through the players name from the server to the client or vise versa to be able to do this. If you do not know how to do such please explain to me more what you are trying to do and I will see if I can help.

My revive script has two revive scripts inside of ServerScriptService. One script controls the reviver, the other is for the downed person. I’ve already figured out how to disable and reenable the inventory for the reviver. I just can’t figure it out for the downed script.

Essentially what you should do is that once somebody starts reviving a downed player you need to get the name of the Reviver and the name of the Downed;

Once you have the names of both you should seperate them out;

local reviver = 'NavalFi'
local downed = 'asunoandkrito'

Now that you have the name of the downed and who is reviving and they are seperated you need to pass the downed value to the client side through an event or something of your choosing;

Once you have gotten the name of the downed player you are going to set their CoreGui to backpack disabled the same way that you set the reviver’s backpack to disabled.

If you have any other questions please explain what they are

I don’t really know how to script, so I can’t really go with that approach. I’m more interested in Forummer’s response though. I don’t really understand what the lines:

Remote:FireClient(Player, false) 
task.wait(5)
Remote:FireClient(Player, true)

mean

Essentially what he did is was just explaining how you can transfer a bool from the server to the client;

What he does is that he gets the players and the value false then fires to the client;

The client recieves this and titles it as toggle

Toggle = false

he then uses toggle in the code where you disable the backpack so therefore, backpack enabled = toggle which in the same context backpack enabled = false

then after 5 seconds this value is changed to true therefore toggle is now true

this means that backpack enabled = true

You do the exact same thing but instead of changing the true false value you are changing the player value. You need to fire the client on the downed person side and not your side.

I’m not using a Players.PlayerAdded:Connect(function(Player), so what do I replace the Player in
Remote:FireClient(Player, false) with?