Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i add dynamic lighting to a gun?

How do i add dynamic lighting when you fire the gun?

2 answers

local light = game.Workspace.PointLight:Clone() --Put all of this code in the script when it fires.
light.Parent = script.Parent.GUNSHOOTER
wait(HOW LONG YOU WANT IT TO SAY LIGHT) --Also you may have to edit the caps words
script.Parent.GUNSHOOTER.PointLight:Destroy()

This clones the PointLight from Workspace. And then puts it into the Gunshooter of the gun, and then waits for how long you want it to stay that light, and then destroys the light.

An example gun that you could use is : Hyperlaser gun

I can't give you an exact answer, because it varies between each gun, however you make it.

I can give you the basics however.

So you would want to create a function, that fires when the player shoots the gun. After that you could do something like this:

local flashpart = script.Parent.Barrel -- change this to whatever part you would want to flash 

flash = Instance.new("PointLight") 
flash.Parent = flashpart
wait(0.2)
flash:Destroy()

Hope I helped :)

1 comment

0

Thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.