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

WeaponRemover needs fixing. Who can help?

Asked by
painzx3 43
10 years ago

The code works pretty well but at the end I don't know how to utilize the remove() or destroy() function so I was hoping if someone could just tell me the little snippet of code I would need to remove all players weapons at the end of the round. Here's the code.

Red = game.Workspace.Bpos
Blue = game.Workspace.Rpos
lobby = game.Workspace.Lpos
weapon1 = game.Lighting["Revolver"]
weapon2 = game.Lighting["Knife"]
Maps ={"Divide", "Karachi"}

function giveTools(player)
    weapon1:Clone().Parent = player.StarterGear
    weapon1:Clone().Parent = player.Backpack
    weapon2:Clone().Parent = player.StarterGear
    weapon2:Clone().Parent = player.Backpack
end

while true do 
    wait(15)-- how long between games.
    local mapName = Maps[math.random(1,#Maps)]
    local message = Instance.new("Message", game.Workspace);
    for i = 3,1,-1 do
        message.Text = "Selecting map in " .. i
        wait(1)
    end
    message.Text = mapName .. " has been chosen!"
    wait(4)
    local map = game.Lighting[mapName]:Clone()
    map.Parent = game.Workspace
    map:MakeJoints()
    message.Text = "Teleporting players..."
    wait(3)
    message:Destroy()
    local players = game.Players:GetChildren()
    for i = 1,#players do
        local p = players[i];
        if p.Character and p.Character:FindFirstChild("Torso") then
            local spawn = false;
            if p.TeamColor == BrickColor.new("Bright red") then
                spawn = Red.CFrame + Vector3.new(0,i*15,0)
            elseif p.TeamColor == BrickColor.new("Bright blue") then
                spawn = Blue.CFrame + Vector3.new(0,i*15,0)
            end
            if spawn then
                p.Character.Torso.CFrame = spawn;
                giveTools(p);
            end
        end
    end 
    wait(15) -- how long each game lasts.
    local players = game.Players:GetChildren()
    for i = 1,#players do
        local p = players[i];
        if p.Character and p.Character:FindFirstChild("Torso")  then 
            p.Character.Torso.CFrame = lobby.CFrame + Vector3.new(0,i*15,0)
        end
    end
    local message = Instance.new("Message", game.Workspace)
    message.Text = "The round has ended!"
    wait(4)
    map:Destroy()
    --message.Text = winner.." has won!"
    message:Destroy()
end

1 answer

Log in to vote
0
Answered by
wjs3456 90
10 years ago

It is very simple. Try this

        place = player.StarterGear;
if place:FindFirstChild("weapon1") then
         place.weapon1:Destroy()
    end
    place = player.Backpack;
    if place:FindFirstChild("weapon1") then
         place.weapon1:Destroy()
    end 
    place = player.Character;
        if place:FindFirstChild("weapon1") then
     place:FindFirstChild("weapon1").Parent = player.Backpack
    wait()
    player.Backpack.weapon1:Destroy()--Basically  this makes it so that if the player has the tool out it will move it to the backpack(removing the CFrame) then destroys it
Ad

Answer this question