Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make tools that deletes itself and clone a new tool into it?

So I've been experimenting and I can't find a solution to this problem, can anyone lend me a hand? this is what I have done so far...

script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
        animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
        animation:Play()
		game.Lighting:findFirstChild("Tool 1"):clone().Parent = player.Backpack
                script.Parent:Remove()
    end)
end)

If anyone can help me with this I would be appreciated :)

1 comment

0

Did you get any errors? Capitalize f in FindFirstChild() and c in Clone()

1 answer

✓ Accepted answer
--Variables
local obj = script.Parent
local player = game.Players.LocalPlayer

local function onActivate()
animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
        animation:Play()
        game.Lighting:FindFirstChild("Tool 1"):Clone().Parent = player.Backpack
        obj:Destroy()

end
end)

obj.Activated:Connect(onActivate)

Many errors in the script. It had a tool cloning to the "player" which was not set up in local. You were using equipped for detecting when a player hits the mousebutton1 which isn't its purpose, instead use Activated. I am not completely sure what this is for but here is what I could help you with.

Have a good day.

4 comments

0

Thanks :D

0

also is this supposed to be a local script?

0

because when i try activating it the end) part have red under line for some reason

0

never mind. i try to figure out and i eventually got it to work! tanks again! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.