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

How to make the backpack enabled when touched a part?

Asked by 5 years ago

I have already made a script about it

1game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
2    local Part = game.Workspace["Backpack?"]
3    Part.Touched:Connect(function(Hit)
4    local player = game.Players:GetPlayerFromCharacter(Hit.Part)
5    if player then
6        game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
7    end
8    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

Log in to vote
0
Answered by 5 years ago

Server:

01local re = Instance.new("RemoteEvent", game.ReplicatedStorage)
02re.Name = "Backpack"
03 
04local part = workspace:FindFirstChild("Part")
05if part then
06    part.Touched:connect(function(touch)
07        local player = game.Players:FindFirstChild(touch.Parent.Name)
08        if player then
09            re:FireClient(true)
10        end
11    end)
12end

Client:

1game:service'StarterGui':SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
2 
3local re = game.ReplicatedStorage:WaitForChild("Backpack")
4 
5re.OnClientEvent:connect(function(bool)
6    game:service'StarterGui':SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, bool)
7end)
0
Replace 'local part = workspace:FindFirstChild("Part")' with the location of your part. User#28313 0 — 5y
0
Thanks!! fortesss7 40 — 5y
0
is it in the same script? fortesss7 40 — 5y
0
no, a localscript for the client (in startergui or playerscripts) and script in severscriptservice i guess User#28313 0 — 5y
Ad

Answer this question