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

How do you make a tool automatically go to your backpack when unlocked?

Asked by 5 years ago
Edited 5 years ago

Heres the script that is in the button to activate the script in ServerScriptService:

script.Parent.MouseButton1Click:connect(function()
    game.ReplicatedStorage.EquipEvents.Equip1:FireServer() 
end)

Then heres the script that gives it to you in ServerScriptService:

game.ReplicatedStorage.EquipEvents.Equip1.OnServerEvent:connect(function(player)
    local char = player.Character
    local item = game.ReplicatedStorage.Items:FindFirstChild("Pizza")
    if player.leaderstats.Pounds.Value >= 25 then
    if not player.Backpack:FindFirstChild("Pizza" ) then
        if not char:FindFirstChild("Pizza") then
            item:Clone().Parent = player.Backpack
            end
        end
    end
end)

Answer this question