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

When clicked why isn't it taking away the sword?

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 = false 
Tool = game.Lighting:findFirstChild(toolname):remove()
Tool.Parent = game.Players:findFirstChild(char.Name).Backpack
wait()
Tool = true 
end)
end)
end)

I am working on a game and I can't get this script to remove the weapon that is in the players backpack.

1 answer

Log in to vote
0
Answered by 9 years ago

I don't really understand this part...

Tool = game.Lighting:findFirstChild(toolname):remove()
Tool.Parent = game.Players:findFirstChild(char.Name).Backpack

If you're trying to remove a weapon from a Player's Backpack, it's way more simpler.

local Toolname = "LinkedSword"

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Char)
        if Player.Backpack:findFirstChild(ToolName) then
            Player.Backpack:findFirstChild(ToolName):Remove()
        end
    end)
end)

You said remove the tool, so..

Ad

Answer this question