Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Creating a blinding effect using BloomEffect?

Asked by 7 years ago

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.

0
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 TheUniPiggy 77 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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()
0
I realised I forgot to put the Position in -site, so now its site.Position. But now it returns with another error which is that its a nil value. I'm not great with function params and I'm trying so that the script detects whether or not the player is within a 500 stud radius. Alectfenrir123 10 — 7y
0
Just tried proj.Position now and all the errors are gone, but for some reason the blinding effect did not occur. Well that's a problem for another script. Thanks for your help though! Alectfenrir123 10 — 7y
0
Hey, don't forget to accept my answer, then :P OldPalHappy 1477 — 7y
0
I would but where is the button to do so? Alectfenrir123 10 — 7y
0
Should be at the top of my answer. If you don't see it, try re-logging. If you still don't see it, report the problem. c: OldPalHappy 1477 — 7y
Ad

Answer this question