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

When clicked, why doesn't it remove your tool?

Asked by 9 years ago
toolname = "LinkedSword" 


Tool = true 
game.Players.PlayerAdded:connect(function(newPlayer)
newPlayer.CharacterAdded:connect(function(char)
script.Parent.ClickDetector.MouseClick:connect(function()
if Tool == false then return end 
wait()
Tool = game.Lighting:findFirstChild(Toolname):remove()
Tool.Parent = game.Players:findFirstChild(char.Name).Backpack
game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Char)
        if Player.Backpack:findFirstChild(Toolname) then
            Player.Backpack:findFirstChild(Toolname):remove()
end
end)

Could you help me please?

0
You are missing an end, also use Destroy EzraNehemiah_TF2 3552 — 9y

1 answer

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
9 years ago

Problems

You're using remove(), use Destroy()!

You forgot an end.


Fixes

Replaced your removes with Destroy()

Added an end


Script

toolname = "LinkedSword" 
Tool = true 

game.Players.PlayerAdded:connect(function(newPlayer)
    newPlayer.CharacterAdded:connect(function(char)
        script.Parent.ClickDetector.MouseClick:connect(function()
            if Tool == false then return end 
            wait()
            Tool = game.Lighting:findFirstChild(Toolname):Destroy()
            Tool.Parent = game.Players:findFirstChild(char.Name).Backpack
            game.Players.PlayerAdded:connect(function(Player)
                Player.CharacterAdded:connect(function(Char)
                    if Player.Backpack:findFirstChild(Toolname) then
                        Player.Backpack:findFirstChild(Toolname):Destroy()
                    end
                end)
            end)
        end)
    end)    
end)
Ad

Answer this question