So I'm trying to make it so that in a certain radius, players near the exploded object will be temporary blinded using BloomEffect. The problem is I'm getting this error in the output:
"Workspace.ChargedProjectile.FiredProjectile.Decimate:27: bad argument #2 to '?' (Vector3 expected, got nil)"
Because of this, my script isn't working. Please help!
Here is the code inside the object that will explode
local proj = script.Parent
flashEvent = Instance.new("RemoteEvent")
flashEvent.Parent = game.ReplicatedStorage
flashEvent.Name = "FlashEvent"
function Explode(site)
for _,player in next,game.Players:GetPlayers() do
if player.Character then
local char = player.Character
if (char.Torso.Position - site).magnitude <= 500 then
game.ReplicatedStorage.FlashEvent:FireClient(player)
end
end
end
end
function decimate()
local propellant = Instance.new("BodyVelocity")
propellant.Parent = proj
propellant.Velocity = Vector3.new(0,1000,0)
wait(1)
Explode()
local explosion = Instance.new("Explosion")
explosion.Parent = game.Workspace
explosion.Position = proj.Position
proj:Destroy()
end
decimate()
Please note where it fires the client, it connects to a local script which activates the blinding effect. No issues occur on that local script, just this one.

1 comment
Have you tried doing it out of the function and commenting the code in the function to see if it's a bug in a function or maybe you could manually write
script.Parent. Just a few ideas :P