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

How do I make this if statement recognize if the player is dead or alive?

Stand.OnServerEvent:Connect(function(player,active)
	if active == true then
		local Character = player.Character
		local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
		
		local myStand = workspace:WaitForChild(player.Name.." Stand")
		myStand:Destroy()
		
		Stand:FireClient(player)
	end
end)

If active is true, it does the following. The thing is, i need the if statement to also activate if the player died. I know you can add an "or" after the active == true, so it will be

if active == true or ... then

but I dont know how to make it recognized if your alive.

Btw, this is in a Script not a local script.

1 answer

✓ Accepted answer

oh! active will not affect the player. Do this:

Stand.OnServerEvent:Connect(function(player,active)
    if Character.Humanoid.Health <= 0 then
        local Character = player.Character
        local HumanoidRP = Character:WaitForChild("HumanoidRootPart")

        local myStand = workspace:WaitForChild(player.Name.." Stand")
        myStand:Destroy()

        Stand:FireClient(player)
    end
end)

What I did was check if the character has 0 health, and if they do, or anything below 0, then it will run your event!

9 comments

0

theres an error in the output that says " 21:02:51.476 - Humanoid is not a valid member of Player".

0

Oh! Change player to character. My bad

0

I have edited the script

0

Ok, now it works, but it only deletes the stuff inside the script. How do i get it to delete the folder itself aswell?

0

If myStand is in the Folder, then do myStand.Parent. Make sure to mark the answer as correct if it helped you!

0

ok, one more question, how do i define player? can i do local player = ... or something?

0

Like outside of Stand.OnServerEvent:Connect(function(player,active)

0

uh thats a question for a different day! Hope this helped! Make sure to mark my post as the answer if it was right!

0

Understandable, thanks!

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