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

Please help I want to do is when a player touch brick their tools respawn?

Asked by 5 years ago

Please help I've been trying to fix this glitch for hours. Here's the script.

while true do 
wait(20) --time in seconds 
if tool == nil then 
tool = clone:Clone() 
tool.Parent = script.Parent 
end 
end

Thanks

0
can u pls send a complete snippet TheluaBanana 946 — 5y
0
also ur checking wether the tool does not exist and the cloning the tool if it does not exist. this is wong TheluaBanana 946 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You have it all wrong.

You have to have 3 things set up:

1: The tool in either the ReplicatedStorage or Lighting 2: A touch script 3: Your character's Backpack

This is how the script would look:

(Regular script inside of the brick)

script.Parent.Touched:Connect(function(hit)
    local tool = game.ReplicatedStorage:WaitForChild("RenameTool")
    local starterpack = game.Players:FindFirstChild(hit.Parent.Name).Backpack:GetChildren()
    for i, v in pairs(starterpack) do
        if v == nil then
            tool:Clone().Parent = game.Players:FindFirstChild(hit.Parent.Name).Backpack
        else
            return print("Already have tool")
        end
    end
end)

(This was off the top of my head, I haven't tested it sooo gl :P)

0
Why would it be in Lighting? And why are you returning a value from an event listener? User#24403 69 — 5y
0
eh `return` makes it look more professional, you could just do "print" but meh why not use return? works the same way :3 (also you can put tools in lighting for cloning) supercoolboy8804 114 — 5y
Ad

Answer this question