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

How to check if reset was clicked?

This might be impossible but I am wondering if you can check if someone clicked reset in the menu. Thanks, KIheros

1 comment

0

You could use the Humanoid.Died event, but there is no way of checking whether the button has been clicked, no.

1 answer

✓ Accepted answer

This assumes that you have made all of the scripts in your game

If you didn't kill them, it's probably not unfair to say that they might have killed themselves. When Humanoid.Died fires, check if one of your scripts killed the humanoid (You'll need to set up a broadcast or BoolValue or something to tell scripts that we're looking at murder). If it wasn't one of your scripts, then they reset.

As an example, you can have a suicide watch script like this

game.Players.PlayerAdded:connect(function(p)
	p.CharacterAdded:connect(function(c)
		local hum = c:WaitForChild("Humanoid");
		local murder = Instance.new("BoolValue");
		murder.Name = "Murder";
		murder.Value = false;
		murder.Parent = hum;
		-- local torso = c:WaitForChild("Torso");
		hum.Died:wait();
		if murder.Value then
			-- Killed by a script
		else
			-- Suicide
		end;
	end);
end);

And then in a killing script you can write this

if humanoid then
	-- Ayy let's get 'im
	humanoid.Murder.Value = true;
	humanoid.Parent:BreakJoints();
end

There is one more possibility, which is that the Player jumped off the edge. To catch that, try this:
(Assumes that you've got a Torso predefined from the CharacterAdded with `local torso = c:WaitForChild("Torso"))

else -- If it's not murder
	if torso.Position.Y < workspace.FallenPartsDestroyHeight then
		-- Also not murder, unless they were pushed, but not a reset.
	else
		-- Reset.
	end;
end;

5 comments

0

I removed the edit I am so happy you said this!

0

Tada

0

Clever thinking, eLunate. I'm voting you up.

0

I did make all the scripts in my game but I am wondering how to check as I use another object while the player is destroyed so I can reset the object when I click reset. but maybe I should just not even have reset work and have an extra button or something I'll still accept cause its a great answer anyway!

0

I got on my computer and added some code, and revised the answer.

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