Greetings,
Within the past week, I have began to be working on the Dev work for my Haunt Group. Essentially, we are like a virtual Halloween Event, much like Halloween Horror Nights. At the moment, I am in the process of setting up the “Scare Actor” NPC’s. I already have a script set up using magnitude to where they play a certain animation whenever a player gets close to it. This happens locally.
However, for some of these NPC’s I’d love to create a strobe effect that is in sync with the “Scare Actor” to give players a more immersive experience. So far, I haven’t had much luck as I’m not really sure how to approach this. I’ve gotten as far as how to spawn in a point light into a new part utilizing the same script, but getting that same point light to be removed and created again would make the script insanely long and a bit confusing to configure for other NPCs. I’m wondering if there would be an easier solution to this?
- What do you want to achieve? Get a Strobe Light Effect to go off in sync with the NPC, and stop after the animation is over.
Would it at all be possible to add this effect in the same script to keep things compact, or would I wand to try another method?
NPC Script Using Magnitude Below:
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local char = plr.Character or plr.Character:wait()
local humroot = char:WaitForChild("HumanoidRootPart")
local NPC = workspace:WaitForChild("TestActor") -- Change the name of the actor you want to control.
local npcHumanoid = NPC:WaitForChild("Humanoid")
local npcHumanoidRP = NPC:WaitForChild("HumanoidRootPart")
local db = false
local sound = game.Workspace.ScareSounds.Test -- Change path to the sound you want.
game:GetService("RunService").RenderStepped:Connect(function()
if (humroot.Position - npcHumanoidRP.Position).magnitude <= 10 then
if not db then
db = true
local Animation = npcHumanoid:LoadAnimation(script.Animation)
Animation:Play()
sound:Play()
wait(5) -- The Duration of the animation
Animation:Stop()
wait(10) -- Scare Cooldown.
db = false
end
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.