so i wanted to add a constantly changing point light to the projectile part, like the square thing. i don’t know if i would need to preload it or make the color random but it just won’t parent to the light source. i also want to know some tips to do this in a modular way.
also, how would i also add it to the debris function? so it’s also on the tween that sort of fades out when shooting?
local function shootFunction(begin, direction)
local center = begin + direction / 2
local distance = direction.Magnitude
local random = Random.new()
local projectile = Instance.new("Part")
projectile.Parent = folder
projectile.Anchored = true
projectile.CastShadow = false
projectile.CanCollide = false
projectile.CanQuery = false
projectile.Massless = true
projectile.Material = Enum.Material.Neon
projectile.Color = rainbow
projectile.CFrame = CFrame.new(center, begin)
projectile.Size = Vector3.new(.2, .2, distance)
local light = Instance.new("PointLight") --this is the code problem
light.Color = rainbow
light.Range = 100
light.Brightness = 10
light.Parent = projectile
-- light.Parent = CFrame.new(projectile) this line isn't used but it creates a cool lightshow effect
local fade = tween:Create(projectile, TweenInfo.new(time), {Transparency = 1}):Play()
debris:AddItem(projectile, .1)
end
also i can confirm it works when i parent it an existing part so there’s that
however when using this modified code, it will select the random rainbow color and stick with it without always color changing. it’s a randomized bug basically
in this case it’s purple and butchers my cpu
it’s this that i’m trying to recreate