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

Arrest tool not working?

Asked by 9 years ago

this model http://www.roblox.com/Police-Arrest-item?id=149331072 is a tool used to arrest someone by changing there team to the arrested team and respawning them into a cell.

I do not understand the script as when It try it they team as neutral and appear in the centre of the map.

teams in the game: New Yeller = Civilain Really blue = Police Bright red = prison there is two scripts: sword script:

local lastPlayer = nil
local Tool = script.Parent
local Sword = Tool.Handle
local debounce = false

local shield
local shieldMesh

local vCharacter

local damage = 0
local judgement

Tool.Enabled = true

Go = true

function touched(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if debounce == true then
            return
        end
            debounce = true
        if player.Name == "Moolah60" or player.Name == "Nightgaladeld" or player.Name == "bob104810" or player.Name == "305305" or player.Name == "Cuyler" or player.Name == "slothen123" or player.Name == "logan1171416" or player.Name == "imnotaguestimagirl" or player.Name == "deceptional" or player.Name == script.Parent.Parent.Name then
            debounce = false
            return
        end
        if player.Character.Humanoid.Health == 0 then
            debounce = false
            return
        end
        if script.Parent.On.Value == true then
            return
        end
        if player.PlayerGui:FindFirstChild("Arrest") or player.PlayerGui:FindFirstChild("Confirm") then
            return
        end
        if player.TeamColor ~= BrickColor.new("New Yeller") then
            player.Character.Humanoid.WalkSpeed = 0
            for i,v in pairs(player.Backpack:GetChildren()) do
                v:remove()
            end
            for i,v in pairs(player.Character:GetChildren()) do
                if v.className == "Tool" then
                    v:remove()
                end
            end
            if player:FindFirstChild("JobValue") then
                player.JobValue.Value = 0
            end
            script.Parent.On.Value = true
            script.Parent.Confirm.Frame.Player.Value = player.Name
            script.Parent.Confirm.Frame.TextLabel.Text = "Do you want to arrest "..player.Name.."?"
            script.Parent.Confirm:clone().Parent = game.Players:GetPlayerFromCharacter(script.Parent.Parent).PlayerGui
        else
            player:SaveNumber("TimeInJail",0)
            player:SaveBoolean("inJail",false)
            if player:IsInGroup(1065451) then
                player.TeamColor = BrickColor.new("Really blue")
            if player:FindFirstChild("JobValue") then
                player.JobValue.Value = 25
            end
                player:LoadCharacter()
            else
                player.TeamColor = BrickColor.new("New Yeller")
                player:LoadCharacter()
            end
        end
        wait(1)
    end
    debounce = false
end

function tagHumanoid(humanoid, player)
    if humanoid ~= nil then 
        creatorTag = Instance.new("ObjectValue")
        creatorTag.Name = "creator"
        creatorTag.Value = player
        creatorTag.Parent = humanoid 
    end
end

function untagHumanoid(humanoid)
    if humanoid ~= nil then 
        tag = humanoid:FindFirstChild("creator")
        if tag ~= nil then 
            tag:Remove()
        end
    end
end

function onActivated()
    if Tool.Enabled == false then
        return 
    end
    Tool.Enabled = false
    vCharacter = Tool.Parent
    myTorso = vCharacter:FindFirstChild("Torso")
    if myTorso == nil then 
        return
    end

    wait(0.5)
    Tool.Enabled = true

end

function onEquipped()
    script.Parent.AnimateScript.Disabled = false
    print("On Equip")
    vCharacter = Tool.Parent
    Tool.Grip = CFrame.new(0, -0.5, 0.800000012, -4.37113883e-008, -1, 0, 1, -4.37113883e-008, 0, 0, 0, 1)
    while Sword:FindFirstChild("Mesh") == nil do wait() end 
    Sword.Mesh.MeshId = "http://www.roblox.com/asset/?id=82264918"
    Sword.Mesh.TextureId = "http://www.roblox.com/asset/?id=82265067" 
    torso = vCharacter:FindFirstChild("Torso")  
    if vCharacter:FindFirstChild("Shield") == nil and torso ~= nil then

        shield = Instance.new("Part")
        shield.FormFactor = 3
        shield.Name = "Shield"
        shield.Size = Vector3.new(2, 0.2, 2.5)
        shield.Shape = "Block"  
        shield.Parent = vCharacter
        shield.CanCollide = false

        shieldMesh = Instance.new("SpecialMesh")
        shieldMesh.MeshId = "http://www.roblox.com/asset/?id=82265009"
        shieldMesh.Scale = Vector3.new(1.1, 1.1, 1.1)
        shieldMesh.Name = "Mesh"
        shieldMesh.TextureId = "http://www.roblox.com/asset/?id=82265116"
        shieldMesh.Parent = shield      

        shieldWeld = Instance.new("Weld")
        shieldWeld.Part0 = torso
        shieldWeld.Part1 = shield
        shieldWeld.Name = "ShieldHolder"
        --shieldWeld.C1 = CFrame.new(Vector3.new(0, -0.7, 0)) * CFrame.Angles(math.pi/2, math.pi, 0)
        shieldWeld.C1 = CFrame.new(Vector3.new(0, 0, 0)) * CFrame.Angles(0, math.pi, 0)
        shieldWeld.Parent = torso       
        script.Parent.On.Value = false  
    end
end

function onUnequipped()
    torso = vCharacter:FindFirstChild("Torso")
    if torso then 
        shield = vCharacter:FindFirstChild("Shield") 
        shieldWeld = torso:FindFirstChild("ShieldHolder")
    end
    if shield then shield:Remove() end
    if shieldWeld then shieldWeld:Remove() end

end

Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(onUnequipped)
Tool.Activated:connect(onActivated)
somanyhits = false

Sword.Touched:connect(function(hit)
    ypcall(function () touched(hit) end)
end)

and another in a gui

function down(choice)
    if game.Players:FindFirstChild(script.Parent.Player.Value) == false or script.Parent.Player.Value == "None" then
        game.Workspace[script.Parent.Parent.Parent.Parent.Name]["Police Beta"].On.Value = false
        script.Parent.Parent:Destroy()
    end
    game.Debris:AddItem(script.Parent.Parent,3)
    local selected = game.Players[script.Parent.Player.Value]
    local player = script.Parent.Parent.Parent.Parent
    if choice == "Yes" then
        local timesJailed = selected:LoadNumber("JailedTimes")+1
        local jailTime = 300 + (50*timesJailed/2)
        if jailTime > 600 then
            jailTime = 600
        end
        selected:SaveBoolean("inJail",true)
        selected:SaveNumber("TimeInJail",jailTime)
        selected.TeamColor = BrickColor.new("Bright red")
        player.Character["Police Beta"].Arrest.Frame.Player.Value = selected.Name
        player.Character["Police Beta"].Arrest:clone().Parent = script.Parent.Parent.Parent
        selected.Character.Humanoid.Health = 0
        game.Workspace[script.Parent.Parent.Parent.Parent.Name]["Police Beta"].On.Value = false
        script.Parent.Parent:Destroy()
    elseif choice == "No" then
        selected.Character.Humanoid.WalkSpeed = 16
        for i,v in pairs(selected.StarterGear:GetChildren()) do
            v:clone().Parent = selected.Backpack
        end
        local tc = selected.TeamColor
        for i,v in pairs(game.Lighting.Teams:GetChildren()) do
            if v.TeamColor == tc then
                for a,s in pairs(v:GetChildren()) do
                    if s.className == "Tool" or s.className == "HopperBin" then
                        s:clone().Parent = selected.Backpack
                    end
                end
            end
        end
        game.Workspace[script.Parent.Parent.Parent.Parent.Name]["Police Beta"].On.Value = false
        script.Parent.Parent:Destroy()
    end
end

script.Parent.ImageLabel.Image = "http://www.roblox.com/thumbs/avatar.ashx?x=150&y=150&format=png&username="..script.Parent.Player.Value
script.Parent.TextLabel.Text = "Do you want to arrest "..script.Parent.Player.Value.."?"

script.Parent.Yes.MouseButton1Down:connect(function ()
    down("Yes")
end)

script.Parent.No.MouseButton1Down:connect(function ()
    down("No")
end)

Please help!

Answer this question