How to make camera tool emit a flash?

Basically I have this camera tool that’s already animated n all and even plays a small click noise when used. My problem is that I’d like for it to also make a small “flash” when used to give more life to it. I’m not entirely sure how to script it and couldn’t find anything that relates to this issue so I hope someone will be able to help. My idea for now is that I weld a disabled particle emitter to a part of the camera and have it become enabled when clicked and then disabled again after a few seconds.

How the tool looks in the workplace:
Screenshot (254)

The CameraScript:

local Tool = script.Parent
local Player = Tool.Parent.Parent
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = Tool:WaitForChild("Camera")
local BodyAttach = Camera:WaitForChild("BodyAttach")
local Motor = Instance.new("Motor6D")
Motor.Part0 = Player.Character:WaitForChild("Torso")
Motor.Part1 = BodyAttach
Motor.Name = Tool.Name
Motor.Parent = Player.Character:WaitForChild("Torso");

enabled = true

function onActivated()
	if not enabled  then
		return
	end

	enabled = false
	wait(1)
	BodyAttach.Click:Play()
	wait(3)	
enabled = true

end

script.Parent.Activated:connect(onActivated)

The Handler script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local Cooldown = require(Modules:WaitForChild("Cooldown"))
local PlayerScripts = Players.LocalPlayer:WaitForChild("PlayerScripts")
local Functions = PlayerScripts:WaitForChild("Functions")
local CooldownF = Functions:WaitForChild("Cooldown")

local Tool = script.Parent
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = Tool:WaitForChild("Camera")
local BodyAttach = Camera:WaitForChild("BodyAttach")


if not Character:IsDescendantOf(workspace) then
	while not Character:IsDescendantOf(workspace) and Character == Player.Character do task.wait() end
	if Player.Character ~= Character then return end
end

local IdleAnimation = Instance.new("Animation")
IdleAnimation.AnimationId = "rbxassetid://9648710323"
local I = Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(IdleAnimation)

local UseAnimation = Instance.new("Animation")
UseAnimation.AnimationId = "rbxassetid://9648708661"
local A = Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(UseAnimation)


Tool.Activated:Connect(function()
	if Player:GetAttribute("Grabbing") or Cooldown:IsOnCooldown(Player) or A.IsPlaying then return end

	A:Play()

	CooldownF:Invoke(2)
end)

Tool.Equipped:Connect(function()
	I:Play()
end)

Tool.Unequipped:Connect(function()
	A:Stop()
	I:Stop()
end)

A video of the camera tool in action (I forgot to record audio but please believe me that there is a click sound lol):

Any n all help is appreciated.

Hello!

A simple solution to this is use a surface or spot light. You can have a disabled surface or spot light in the part that flashes, then when it takes a picture, have it turn on then off after (you can really make the way it flashes how you want it to be in scripting) like:

Example Code
script.Parent.SurfaceLight.Enabled = true -- turns light on
wait(0.5) -- makes it stay on for 0.5 secs
script.Parent.SurfaceLight.Enabled = false -- turn light off 
-- repeat, but faster and final flash
wait(0.1) 
script.Parent.SurfaceLight.Enabled = true
wait(0.1)
script.Parent.SurfaceLight.Enabled = false

And to be a little more extra, you can have a part in the camera like the actual flasher become neon, and follow along with the SurfaceLight, like this:

Above Code, Added Material Lines
script.Parent.SurfaceLight.Enabled = true -- turns light on
script.Parent.Material = "Neon" -- makes flasher appear on
wait(0.5) -- makes it stay on for 0.5 secs
script.Parent.SurfaceLight.Enabled = false -- turn light off 
script.Parent.Material = "SmoothPlastic" -- makes flasher appear off
-- repeat, but faster and final flash
wait(0.1) 
script.Parent.SurfaceLight.Enabled = true
script.Parent.Material = "Neon" -- makes flasher appear on
wait(0.1)
script.Parent.SurfaceLight.Enabled = false
script.Parent.Material = "SmoothPlastic" -- makes flasher appear off

Hope These Help!

1 Like

I’ll try this out now! I’ll let you know how it goes.

1 Like

That seemed to work as planned! Although I personally went with a SurfaceLight and ParticleEmittor inside of two different attachments so I could position them to my liking (although the particle is delayed for some reason, I’ll have to try n fix that.)

New CameraScript:

local Tool = script.Parent
local Player = Tool.Parent.Parent
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = Tool:WaitForChild("Camera")
local BodyAttach = Camera:WaitForChild("BodyAttach")
local ParticleEmitter = Camera.Flash.Attachment2:WaitForChild("ParticleEmitter")
local SurfaceLight = Camera.Flash.Attachment1:WaitForChild("SurfaceLight")
local Motor = Instance.new("Motor6D")
Motor.Part0 = Player.Character:WaitForChild("Torso")
Motor.Part1 = BodyAttach
Motor.Name = Tool.Name
Motor.Parent = Player.Character:WaitForChild("Torso");

enabled = true

function onActivated()
	if not enabled  then
		return
	end

	enabled = false
	wait(1)
	BodyAttach.Click:Play()
	ParticleEmitter.Enabled = true
	SurfaceLight.Enabled = true
	task.wait(.6)
	ParticleEmitter.Enabled = false
	SurfaceLight.Enabled = false
enabled = true

end

script.Parent.Activated:connect(onActivated)

Video showing it off (sorry if the light is hard to see):

1 Like

Figured out the particle delay problem! Instead of

	ParticleEmitter.Enabled = true
	ParticleEmitter.Enabled = false

Replace it with:

ParticleEmitter:Emit(1)
ParticleEmitter:Clear()

Looks Awesome! Glad I could help.

You know you might wanna adjust the surface light properties so the light emmitting is more shown, such as the light face, it looks like it shines on the player. And other stuff like brightness and range.

Anyway, glad I could help once again!

1 Like