Explosion.Visible = true/false

Oh no doubt – I wasn’t arguing against it. The inability to set the parent of something right after it was created is an obnoxious gotcha that I felt you should know how to bypass.

[quote] “Something unexpectedly tried to set the parent of Explosion to NULL while trying to set the parent of Explosion. Current parent is Workspace.”

You need to delete it in a new thread – not wait().

local explosion = createExplosion()
spawn(function() explosion:Destroy() end) [/quote]

Try this instead:

workspace.DescendantAdded:connect(function(Descendant)
    if Descendant:IsA("Explosion")  then
        coroutine.yield()
        Descendant:Destroy()
    end
end)

@Finite: Nope :frowning:

[quote] @Finite: Nope :frowning:

[/quote]

D’aw.

Maybe this then! (server side code)

local function NewExplosion()
    local Obj = Instance.new("Explosion")
    Obj.Parent = workspace.CurrentCamera
    return Obj
end

Then you can use that as an in-place replacement for creating Explosions and they will only show up to the server (and hopefully still apply the explosion force)

[quote=FiniteReality]Maybe this then! (server side code)

local function NewExplosion()
    local Obj = Instance.new("Explosion")
    Obj.Parent = workspace.CurrentCamera
    return Obj
end

Then you can use that as an in-place replacement for creating Explosions and they will only show up to the server (and hopefully still apply the explosion force)[/quote]

This hides the explosion! It can still kill humanoids and break brick walls. But it stops applying force to loose parts after they were blown from a wall. Very weird and broken behavior

Also, putting the explosion in Terrain produces the same buggy results as putting it in Camera

Deleting the explosion or putting it under a camera is really hacky and messes with a lot of its behaviors/Explosion.Hit events, so that’s not really an ideal solution at all.

Explosions wait a frame before exploding IIRC. This implies that the same should happen on the client. What you could do is remove the explosion on the client as soon as it’s added. That way, the client shouldn’t see any explosion but the server should still work as expected.

Somebody may need to confirm this, you may also need to design an explosion handling script.

[quote] Explosions wait a frame before exploding IIRC. This implies that the same should happen on the client. What you could do is remove the explosion on the client as soon as it’s added. That way, the client shouldn’t see any explosion but the server should still work as expected.

Somebody may need to confirm this, you may also need to design an explosion handling script. [/quote]

Yeah, no, that doesn’t work. We already tried this, unfortunately.

It’s been about two years since I posted this thread, but I’LL BE DARNED IT SHOULD STILL HAPPEN. I want so badly to make custom particle explosions without the default effects taking place.

6 Likes

That is absurd, haha.

Heres a neat fact.
There is code in ROBLOX Battle directly ported from ROBLOX’s C++ explosion code, that allows you to implement explosion forces without an actual explosion object.

--world->ticklePrimitive(p, true);
--Vector3 delta = (p->getCoordinateFrame().translation - position);
local delta = p.Position - (Rocket.CFrame * CFrame.new(0,0,-2)).p
--Vector3 normal = 
--	(delta == Vector3::zero())
--	? Vector3::unitY()
--	: delta.direction();
local normal = (delta == Vector3.new(0,0,0))
				        and Vector3.new(0,1,0)
				        or  delta.unit

--float radius = p->getRadius();
local radius = p.Size.magnitude / 2				
				
--float surfaceArea = radius * radius;
local surfaceArea = radius * radius
				
--Vector3 impulse = normal * blastPressure * surfaceArea * (1.0f / 4560.0f); // normalizing factor
local impulse = normal * BLAST_PRESSURE * surfaceArea * (1.0 / 4560.0)
				
-- How much force to apply (for characters, ramp it down towards the edge)
local frac;
if isInCharacter then
	frac = 1 - math.max(0, math.min(1, (r-2)/blastRadius))
else
	frac = 1
end				
				
--p->getBody()->accumulateLinearImpulse(impulse, p->getCoordinateFrame().translation);
local currentVelocity = p.Velocity
local deltaVelocity = impulse / p:GetMass() -- m * del-v = F * del-t = Impulse
local bodyV = Instance.new('BodyVelocity', p)
bodyV.velocity = currentVelocity + deltaVelocity
local forceNeeded = 196.2 * p:GetMass() -- F = ma
bodyV.maxForce = Vector3.new(forceNeeded, forceNeeded, forceNeeded) * 10 * frac
game.Debris:AddItem(bodyV, 0.2/FORCE_GRANULARITY)
				
--p->getBody()->accumulateRotationalImpulse(impulse * 0.5 * radius); // a somewhat arbitrary, but nice torque
local rotImpulse = impulse * 0.5 * radius
local currentRotVelocity = p.RotVelocity
local momentOfInertia = (2 * p:GetMass() * radius * radius / 5) -- moment of inertia = 2/5*m*r^2 (assuming roughly spherical)
local deltaRotVelocity = rotImpulse / momentOfInertia 
local rot = Instance.new('BodyAngularVelocity', p)
local torqueNeeded = 20 * momentOfInertia -- torque = r x F, want about alpha = 20 rad/s^2, alpha * P = torque
rot.maxTorque = Vector3.new(torqueNeeded, torqueNeeded, torqueNeeded) * 10 * frac
rot.angularvelocity = currentRotVelocity + deltaRotVelocity
game.Debris:AddItem(rot, 0.2/FORCE_GRANULARITY)
11 Likes

Yeah, I’ve known this. Not a suitable alternative for an object, and especially a terrible workaround for something as simple as wanting explosions without visuals.

1 Like

hey, this works. Downside is 1/30s latency.

local function Invisisplode(properties, OnHit)
	coroutine.resume(coroutine.create(function()
		wait()
		local e = Instance.new('Explosion', workspace)
		for prop, val in next, properties do
			e[prop] = val
		end
		if OnHit then
			e.Hit:connect(OnHit)
		end
		if not properties.Parent then
			e.Parent = workspace
		end
		RunService.Heartbeat:wait()
		e:Destroy()
	end))
end
Invisisplode({Position = workspace.Fractality.Head.Position, BlastRadius = 10})

It works by creating the explosion right after rendering starts and destroying it right after the physics step.

2 Likes

Downside is also that it only works if the explosion is locally created. :C I appreciate all the attempts at workarounds in this thread but they’re all too much or require scrapping the Explosion object entirely for something so small.

1 Like

Looks like @ScrapYard 's code works fine on the server. Doesn’t have the flash that the smallest wait() has before destroying the explosion.

Edit: Nevermind, the bricks snap back to their position on the server. LOL

1 Like

It’s working for me on a 2-player test server (server script, PGS, filtering) as well as online mode, sounds like you might be running the script locally?

Invisible SS Explosion - Roblox invisible server-created explosion is coming out of the red part in the middle of the path

It was on the server but I think I fixed it by increasing the BlastRadius