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

How to check if reset was clicked?

Asked by
Hero_ic 502 Moderation Voter
9 years ago

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

0
You could use the Humanoid.Died event, but there is no way of checking whether the button has been clicked, no. TickerOfTime 70 — 9y

1 answer

Log in to vote
3
Answered by 9 years ago

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;
0
I removed the edit I am so happy you said this! Hero_ic 502 — 9y
0
Tada User#6546 35 — 9y
0
Clever thinking, eLunate. I'm voting you up. DragonODeath 50 — 9y
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! Hero_ic 502 — 9y
0
I got on my computer and added some code, and revised the answer. User#6546 35 — 9y
Ad

Answer this question