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.
On line 23, you don't send anything when you're suppose to. Your function is expecting a Vector3
, but you don't deliver.
I don't know what the vector is is suppose to be, but I'm sure you do. Maybe the position where the explosion took place?
Just a guess would be you meant to send proj.Position
, where you set the explosion to be.
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(proj.Position) local explosion = Instance.new("Explosion") explosion.Parent = game.Workspace explosion.Position = proj.Position proj:Destroy() end decimate()