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

Why Won't this work!!!?? [SOLVED]

Asked by 10 years ago

This is supposed to remove all tools from players unless they're in a special list. Then buy and clone a weapon in their backpacks (Special people should get it free). Why doesn't this work??? Output says there's an error in line 83??

Readers Note: This script has 100 lines.

weaponname = Bearded --You can do WeaponName or "WeaponName"

-- This script removes all the weapons/items of anybody who touches it, except for those whose names
-- are in the "keepers" list and gives the "keepers" the selected tool, for free! Others Pay.
keepers = {"Gortezio", "fahmisack123"}
price = 1 --Charge the knife. Keepers WILL NOT BE CHARGED
-- These are customizeable criteria regarding exactly what is removed, and where it is removed from:
RemoveTools = true -- noobs can kill nwo can they?
RemoveHopperBins = true -- Gotta keep the spectate
RemoveFromBackpack = true -- yeh duh backpack
RemoveFromCharacter = true -- yet again... well duh
RemoveForceField = true -- gotta keep em safe

--[[
Dont mess with the rest of this
unless you are extremely skilled with scripting
]]--



function getPlayer(humanoid)
    local players = game.Players:GetChildren()
    for i = 1, #players do
        if (players[i].Character.Humanoid == humanoid) then return players[i] end
    end
    return nil
end

function checkKeeper(player)
    for i = 1,#keepers do
        if (keepers[i] == player.Name) then return true end
    end
    return false
end

function RemoveWeapons(parent)
    local weapons = parent:GetChildren()
    for i = 1,#weapons do
        if (weapons[i]:IsA("Tool")) and (RemoveTools == true) then
            weapons[i]:Destroy()

        elseif (weapons[i]:IsA("HopperBin")) and (RemoveHopperBins == true) then
            weapons[i]:Destroy()

        end
    end
end

local debounce = false

function onTouched(hit)
    local human = game.Players.LocalPlayer.Character:findFirstChild("Humanoid") 
    if (human == nil) then return end
    local player = getPlayer(human)
    if (player == nil) then return end
    print("Found you")
    if (checkKeeper(player) == true) or (debounce == true) then return end

    debounce = true

    if (RemoveFromBackpack == true) then
        local backpack = player.Backpack
        if (table.maxn(backpack:GetChildren()) > 0) then
            RemoveWeapons(backpack)
        end
    end

    if (RemoveFromCharacter == true) then
        RemoveWeapons(player.Character)
    end

    if (RemoveForceField == true) then
        local charparts = player.Character:GetChildren()
        for i = 1,#charparts do
            if (charparts[i].className == "ForceField") then
                charparts[i]:Destroy()

            end
        end
    end
    player = game.Players.LocalPlayer
    --Now all weapons are removed. Check to see if the player already bought the weapon
    a = game.Lighting.Tools:FindFirstChild(""..weaponname.."")
    bought = script.Parent.bought
    if bought.Value == true then --So the person already bought it and clone it
        a:Clone().Parent = game.Players.LocalPlayer.Backpack
    elseif (checkKeeper(player)==true) then --If it's a "keeper" then clone too
        a:Clone().Parent = game.Players.LocalPlayer.Backpack
    elseif (checkKeeper(player) ~= true) and bought.Value == false then --So he hasn't bought it AND he's not a keeper
        murders = player.leaderstats.Murders
        if murders.Value >= price then --If he has enough money to buy it
            murders.Value = murders.Value - price --Buy the weapon
            a:Clone().Parent = player.Backpack --Clone the weapon
            bought.Value = true --Ensures that he bought it
            --Purchase Complete
        end
    end
end

script.Parent.MouseButton1Click:connect(onTouched)

1 answer

Log in to vote
0
Answered by 10 years ago

At line one, you need to put quote marks around it, or your are just declaring that that variable is equal to a variable 'Beareded' Line1: weaponname = 'Bearded' Line 83: a = game.Lighting.Tools:FindFirstChild(weaponname)

0
Thanks! fahmisack123 385 — 10y
Ad

Answer this question