What i am trying to do is make it so when it impacts at the end of the ray it creates a PointLight and fire.
What i currently have in the script:
wait(1)
local Tool = script.Parent;
local pewsound
local bangsound
local cam
local ggui
enabled = true
automatichold = false
dmged = false
shotgun = false
equipped = false
overheated = false
isZoom = false
-----------------------------------------ONLY EDIT THESE VALUES!!!!!-----------------------------------------
-----!Instructions!-----
--Make sure you have a part in the gun named Barrel, it is where the raycast will shoot from.--
--Just place this script into any gun and edit the values below.--
--Editting anything else will risk breaking it.--
------------------------
Damage = math.random(15,25)
SPS = 4 -- Shots Per Second, gives a limit of how fast the gun shoots.
Recoil = 8 -- [1-10] [1 = Minigun, 10 = Sniper]
WallShoot = false -- Shoots through walls.
GH = false -- [True = RB can't hurt RB.] [False = RB can hurt RB.]
BulletColor = "Bright orange" -- Any Brickcolor will work.
Flash = false
--------------------------------------------------------------------------------------------------------
local zm = Instance.new("Part")
zm.Name = "ZoomZM"
zm.Anchored = true
zm.Transparency = 1
zm.Size = Vector3.new(1,1,1)
zm.CanCollide = false
GunType = 0
function LaserShoot(mouse)
hit = mouse.Hit.p
local StartPos = script.Parent.Barrel.CFrame.p
local rv = (StartPos-hit).magnitude/(Recoil * 20)
local rcl = Vector3.new(math.random(-rv,rv),math.random(-rv,rv),math.random(-rv,rv))
aim = hit + rcl
local P = Instance.new("Part")
P.Name = "Bullet"
P.formFactor = 3
P.BrickColor = BrickColor.new(BulletColor)
P.Size = Vector3.new(1,1,1)
P.Anchored = true
P.CanCollide = false
P.Transparency = 0.5
P.Parent = script.Parent.Parent
local m = Instance.new("CylinderMesh")
m.Name = "Mesh"
m.Parent = P
local c = Instance.new("ObjectValue")
c.Name = "creator"
c.Value = game.Players:findFirstChild(script.Parent.Parent.Name)
pewsound = Tool.Handle:FindFirstChild("Fire")
if pewsound then
pewsound:Play()
end --Brick created. Moving on to next part
local SPos = script.Parent.Barrel.CFrame.p
if WallShoot then
local Part1, Part2, EndPos = RayCast(SPos, (aim-SPos).unit * 999, script.Parent.Parent)
DmgPlr(Part1)
DmgPlr(Part2)
if Part1 and Part2 then
local enddist = (EndPos-SPos).magnitude
P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0,0,-enddist/2) * CFrame.Angles(math.rad(90),0,0)
m.Scale = Vector3.new(.04,enddist,.04)
else
P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0,0,-MaxDist/2) * CFrame.Angles(math.rad(90),0,0)
m.Scale = Vector3.new(.04,MaxDist,.04)
end
elseif not WallShoot then
local Part, Pos = RayCast(SPos, (aim-SPos).unit * 999, script.Parent.Parent)
DmgPlr(Part)
if Part then
local dist = (Pos-SPos).magnitude
P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0,0,-dist/2) * CFrame.Angles(math.rad(90),0,0)
m.Scale = Vector3.new(.1,dist,.1)
else
P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0,0,-MaxDist/2) * CFrame.Angles(math.rad(90),0,0)
m.Scale = Vector3.new(.1,MaxDist,.1)
end
wait(0.2)
end
game.Debris:AddItem(P,.1)
end
Also if anyone knows how to add a way to change the ammo to a cool down with a heat bar that would also be appreciated.

2 comments
outputa/
the script works, just need to know how to add the pointlight and fire on impact