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

Sheriff gun like in Murder Mystery problem? [ERROR]

Asked by
Hybric 271 Moderation Voter
10 years ago

Im trying to make a script [this script in bullet] that if you shoot wrong guy you also die and gun pops up above you, But its not working [Out says: line 3, "humanoid" a nil value

function onTouched(hit)
    local humanoid = hit.Parent:findFirstChild("Humanoid")
        if humanoid.Parent.Name == not Workspace.Trouble.Value then
            script.Parent.Parent:BreakJoints()
            script.Parent.Parent.Colt.Handle.Position = script.Parent.Parent.Torso.Handle.Position + Vector3.new(0,2,0)
            humanoid.Parent.Colt.Handle.Anchored = true
            local sm = Instance.new("Smoke")
            sm = Instance.new("Smoke")
            sm.Name = "Smoke"
            sm.Color = Color3.new(0,85/255,1)
            sm.Opacity = 0.5
            sm.Parent = script.Parent.Parent.Colt.Handle
            sm.Enabled = true
        else
            if humanoid.Parent.Name == Workspace.Trouble.Value then
            Workspace.TroubleDead.Value = true
            wait()
        end
    end
end


function tagHumanoid(humanoid)
    -- todo: make tag expire
    local tag = ball:findFirstChild("creator")
    if tag ~= nil then
        local new_tag = tag:clone()
        new_tag.Parent = humanoid
        debris:AddItem(new_tag, 1)
    end
end



script.Parent.Touched:connect(onTouched)



1 answer

Log in to vote
-1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago
function onTouched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then --Want to see if humanoid exists or if you just hit a wall.
    local humanoid = hit.Parent:findFirstChild("Humanoid")
        if not humanoid.Parent.Name == Workspace.Trouble.Value then --And not should start the If Then Statement.
            script.Parent.Parent:BreakJoints()
            script.Parent.Parent.Colt.Handle.Position = script.Parent.Parent.Torso.Handle.Position + Vector3.new(0,2,0)
            humanoid.Parent.Colt.Handle.Anchored = true
            local sm = Instance.new("Smoke")
            sm = Instance.new("Smoke")
            sm.Name = "Smoke"
            sm.Color = Color3.new(0,85/255,1)
            sm.Opacity = 0.5
            sm.Parent = script.Parent.Parent.Colt.Handle
            sm.Enabled = true
        else
            if humanoid.Parent.Name == Workspace.Trouble.Value then
            Workspace.TroubleDead.Value = true
            wait()
        end
end
    end
end


function tagHumanoid(humanoid)
    -- todo: make tag expire
    local tag = ball:findFirstChild("creator")
    if tag ~= nil then
        local new_tag = tag:clone()
        new_tag.Parent = humanoid
        debris:AddItem(new_tag, 1)
    end
end



script.Parent.Touched:connect(onTouched)
0
I'll test it out.. Hybric 271 — 10y
0
Nope. Hybric 271 — 10y
0
What's the problem now? M39a9am3R 3210 — 10y
Ad

Answer this question