Activating and deactivating a trigger


I’m trying to make it where when a player activates a trigger (through a touch event) on the server side, a remoteEvent then sends who the player is and what trigger was activated to a local script, where a jumpscare is then triggered only for the person who triggered it. The issue I’m having, is that I want it so when the player walks into another trigger, the previous trigger deactivates in the case that the player just ignores the jumpscare and walks past.

I’ve tried multiple different methods but I can’t find any that work. If someone can tell me what I’d need to do that’d be amazing, as I’ve been stuck on this for the past couple days. If you need anymore info or even the scripts I currently have, please ask.

This is a hacky fix, but you can do:

Trigger is hit, Fires to the player’s client.
Client play’s Jumpscare, BOOOOOO!
Client destroys the jumpscare part, So only the player who triggered it can’t activate it.

That’s my idea anyways. lol.

I’ve tried that, the issue with that is if I destroy the part on the client, the server still has the part active. Which in turn means the event still keeps firing. I need to find a way to keep the part server side so other players get the jumpscare, while at the same time figuring out how to make it so if a player activates one trigger, they can’t trigger that same trigger anymore. If the player then decides to ignore the jumpscare and they walk into another trigger, the previous trigger deactivates and the new trigger activates. :frowning:

Sorry if it sounds complicated, you can kinda see why this has been a pain for me lol.

Just keep a table on the server of what triggers each player has activated. When a trigger is touched, check that table to determine if that player has already had it; if not then scare them.

1 Like

It works, I never even thought of doing a table, thank you so much.

1 Like