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

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

Asked by 5 years ago

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 :)

0
Did you get any errors? Capitalize f in FindFirstChild() and c in Clone() Lazarix9 245 — 5y

1 answer

Log in to vote
0
Answered by
proo34 41
5 years ago
--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.

0
Thanks :D NungkiceNicekung 22 — 5y
0
also is this supposed to be a local script? NungkiceNicekung 22 — 5y
0
because when i try activating it the end) part have red under line for some reason NungkiceNicekung 22 — 5y
0
never mind. i try to figure out and i eventually got it to work! tanks again! :) NungkiceNicekung 22 — 5y
Ad

Answer this question