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 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)
0
Replace 'local part = workspace:FindFirstChild("Part")' with the location of your part. User#28313 0 — 4y
0
Thanks!! fortesss7 40 — 4y
0
is it in the same script? fortesss7 40 — 4y
0
no, a localscript for the client (in startergui or playerscripts) and script in severscriptservice i guess User#28313 0 — 4y
Ad

Answer this question