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

I am failing miserably at making an automated dueling system , help anyone?

Asked by
Poine 30
8 years ago

It was working last night and somehow it doesnt work



function win() -- This is empty on purpose end game.Players.PlayerAdded:connect(function(p) repeat wait() until p.Character print "character found i think" p.Character.Humanoid.Died:connect(function() if p.Name == script.Parent.Player1.Value then local p1 = game.Players:FindFirstChild(script.Parent.Player1.Value) local p2 = game.Players:FindFirstChild(script.Parent.Player2.Value) print "p1 ded" wait(1) if p2.Character.Humanoid.Health ~= 0 then script.Parent.Player2.score.Value = script.Parent.Player2.score.Value + 1 wait(0.5) print "p2 gets point" if script.Parent.Player2.score.Value == 5 then win(script.Parent.Player2.Value) end p2:LoadCharacter() p1:LoadCharacter() elseif p2.Character.Humanoid.Health == 0 then end elseif p.Name == script.Parent.Player2.Value then local p1 = game.Players:FindFirstChild(script.Parent.Player1.Value) local p2 = game.Players:FindFirstChild(script.Parent.Player2.Value) print "p2 ded" wait(1) if p1.Character.Humanoid.Health ~= 0 then script.Parent.Player1.score.Value = script.Parent.Player1.score.Value + 1 wait(0.5) print "p1 gets point" if script.Parent.Player1.score.Value == 5 then win(script.Parent.Player1.Value) end p2:LoadCharacter() p1:LoadCharacter() elseif p1.Character.Humanoid.Health == 0 then end end end) end)

It does not print p1 gets point , or p2 gets point. There are no errors in F9

Also for explorer hiearchy(if thats how you spell it) http://prntscr.com/a59osj

Thank you

0
I'm worried as to why you have a model called 'autism' :P JJ_B 250 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I think I know why, you only are checking if the humanoid health is 0 after 1 second, I would recommend an event

p2.Character.Humanoid.Changed:connect(function()
    if p2.Character.Humanoid.Health == 0 then
        -- out what happens when p2 dies here
    end
end)
0
Yes, It is so I can detect a tie , is there any other way to detect a Sword Fight tie , except for waiting 1 second and seeing if they're both dead? Poine 30 — 8y
0
maybe if one player is dead quickly check if the other one is dead? QuantumToast 261 — 8y
Ad

Answer this question