Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make the backpack enabled when touched a part?

I have already made a script about it

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	local Part = game.Workspace["Backpack?"]
	Part.Touched:Connect(function(Hit)
	local player = game.Players:GetPlayerFromCharacter(Hit.Part)
	if player then
	    game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	end
	end)

The script is about the player have already a disabled backpack, when the player touch a part called "BackPack?" the script make the character's backpack enbled again, anybody help me with this?

1 answer

✓ Accepted answer

Server:

local re = Instance.new("RemoteEvent", game.ReplicatedStorage)
re.Name = "Backpack"

local part = workspace:FindFirstChild("Part")
if part then
	part.Touched:connect(function(touch)
		local player = game.Players:FindFirstChild(touch.Parent.Name)
		if player then
			re:FireClient(true)
		end
	end)
end

Client:

game:service'StarterGui':SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local re = game.ReplicatedStorage:WaitForChild("Backpack")

re.OnClientEvent:connect(function(bool)
	game:service'StarterGui':SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, bool)
end)

4 comments

0

Replace 'local part = workspace:FindFirstChild("Part")' with the location of your part.

0

Thanks!!

0

is it in the same script?

0

no, a localscript for the client (in startergui or playerscripts) and script in severscriptservice i guess

This discussion is preserved as it was. New answers, comments, and votes are closed.