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

How can i make an event happen when 2 people are on certain parts?

Asked by 3 years ago

Ok, so I'm trying to make a level to my game where a duo has to find 2 different buttons to press. There are 2 buttons and they need to be on both of them then an event happens. The event is going to be a door at the other side of the maze opening. How can I do this?

1 answer

Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago
Edited 3 years ago

i think the best way to do it is to add a boolean Attribute on both parts (lets say name it activated, and set to false by default)

then you can have two scripts (one for each button) that checks when it is touched, and then check if otherPart.Parent is a character using game.Players:GetPlayerFromCharacter(otherPart.Parent) , if there is a character, do (button):SetAttribute(activated, true) if not, set to false also if touchended, do (button):SetAttribute(activated, false) . and then a separate script that detects when both have the activated attribute set to true. if yes, then something happens. if not, script does nothing until both are activated.

sorry, but that is all i can give. mainly because this is a help site, not a script request site.

here's a link for you if you want some further explanation on how attributes (which are basically custom properties) work.

Attributes

Ad

Answer this question