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

How to make cloned tool STAY in Backpack?

Asked by 9 years ago

So I have a block, when you go through it, it clones a tool from replicated storage and puts it in the player's backpack

It all works, it's just when the player dies, it's not in the backpack anymore, and since it's in the past level they can't go back and re-retrieve it.

Here's the script for the part.

local buttonPressed = false


script.Parent.Touched:connect(function(hit)
    if not buttonPressed then


        buttonPressed = true
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        local Bucket = game.ReplicatedStorage["A Bucket of Water"]:Clone()
        local character = hit.Parent
        local player = game.Players:GetPlayerFromCharacter(character)

        Bucket.Parent = player.Backpack


    end

    wait(10)
    buttonPressed = false

    end
    end)

1 answer

Log in to vote
1
Answered by
Discern 1007 Moderation Voter
9 years ago

There is something named StarterGear in a player, and it clones them to the player's backpack every time they spawn. Therefore, add this:

Bucket:Clone().Parent = player.StarterGear

After line 14.

0
THANK YOU! I NEVER KNEW ABOUT THAT! This will also help with a sword that you pick up near the end of the level. 2 problems solved! Thank you! SpazzMan502 133 — 9y
Ad

Answer this question