This is a ray script for a viewmodel gun. It's supposed to make a bullet and deal 40 damage when a player is touched by it, but the ray is never created.
function createray()
local ray = Ray.new(gun["AN-94"].Flash.CFrame.p (mouse.Hit.p - gun["AN-94"].Flash.CFrame.p) * s.range)
local hit, position = workspace:FindPartOnRay(ray, char, false, true)
local bullet = Instance.new("Part")
bullet.Parent = workspace
bullet.Material = Enum.Material.Neon
bullet.Color = BrickColor.new("New Yeller")
bullet.Anchored = false
bullet.CanCollide = false
bullet.CFrame = (mouse.Hit.p - gun["AN-94"].Flash.CFrame.p)
local vel = Instance.new("BodyVelocity")
vel.Parent = bullet
game:GetService("Debris"):AddItem(bullet, 0.1)
local human = hit.Parent:FindFirstChild("Humanoid")
if human then
human:TakeDamage(40)
end
end
this is just part of a bigger framework script.

3 comments
This just broke the script
I mean, the viewmodel still attaches itself, but the gunshot sound doesn't play and the animations don't play
oh