Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

I'm worried as to why you have a model called 'autism' :P

1 answer

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)

2 comments

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?

0

maybe if one player is dead quickly check if the other one is dead?

This discussion is preserved as it was. New answers, comments, and votes are closed.