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

How do I make a light flicker when a player on a certain team goes near it?

Asked by 1 year ago

In my game, one player is chosen as a "beast" every round and makes lights flicker when near them. I've tried putting invisible parts on the floor scripted with touched events; while it does work, it's really time consuming and non-efficient. So basically my question is: How do I detect when a player in a certain team goes near a SpotLight, PointLight, etc.. and make it do something afterwards?

0
Please provide an explanation as well, but that's not necessary Lemonade9782 4 — 1y

1 answer

Log in to vote
0
Answered by
Antelear 185
1 year ago

Things to look up on;

  1. Magnitude (for distance away and not in a specific area)
  2. :GetPartsInPart() (if you're looking to have it actually happen in a specific area and not how close they are)
  3. Remote Events, for client to server communication if you ever use Magnitude or :GetPartsInPart()
  4. :GetPropertyChangedSignal() (this is for checking if at any point your team is changed and turned into a different one.)
  5. TweenService (for smoothly animation when changing properties.)

The plan is to make a localscript that is copied and parented to the player if they're ever on the team needed for this effect to work (or just use :GetPropertyChangedSignal() as I stated), and use either Magnitude or :GetPartsInPart() to determine if they're close enough to the lights in order to initiate the light flicker effect. This is where tweenservice comes in and you can mess around with the easing styles and seconds it takes to tween and whatnot, here is a link to how the different easing styles look (keep in mind InOut is also a thing).

With this in mind I wish you luck in being able to pull off this flickering light effect. :) (if you want it to dimmer down then TweenService is good to use, if you want it to just straight turn off I recommended making a NEW variable checking if there's at least one person inside the given Magnitude or :GetPartsInPart() field and loop it until they're not in those given areas anymore. I hope this helps in your crusade to making this mechanic work ingame :3 if this indeed helped you then please consider marking this as the answer of which helped you. Good evening!

0
Thank you so much, this rlly helped. Lemonade9782 4 — 1y
Ad

Answer this question