I would like it so that the explosion behaves as it does in the first video
The issues is that the tweening becomes buggy due after a few minutes (part of the explosion model falls downwards)
I’ve tried searching for the issue for a solid few hours with no luck, I am hoping that someone can advise me on how to fix this.
Explosion script:
local rs = game:GetService("ReplicatedStorage");
local ws = game:GetService("Workspace");
local tween_service = game:GetService("TweenService");
local projectile = script.Parent;
local blast_object = rs.classes.bazookoid_trooper.objects.explosion_normal:Clone();
local blacklist = {
["explosion_normal"] = true,
["explosion_ultimate"] = true,
["rocket"] = true
};
local function spawn_blast(part)
if(blacklist[part.Parent.Name] or blacklist[part.Name]) then
return;
end
print(part.Name);
for i,v in pairs(blast_object:GetChildren()) do
if v:IsA("Sound") then
continue;
end
v.Size = Vector3.new(0, 0, 0);
end
projectile.Parent = rs;
blast_object.Parent = ws;
blast_object.PrimaryPart.explosion:Play();
local type = false;
for i,v in pairs(blast_object:GetChildren()) do
if v:IsA("Sound") then
continue;
end
v.Position = projectile.Position;
tween_service:Create(v, TweenInfo.new(0.5, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut), {Size = rs.classes.bazookoid_trooper.objects.explosion_normal:FindFirstChild(v.Name).Size}):Play();
tween_service:Create(v, TweenInfo.new(3.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = v.CFrame * CFrame.Angles(0, math.rad(180 * (type and -1 or 1)), math.rad(45))}):Play();
type = not type;
end
task.wait(3);
type = true;
for i,v in pairs(blast_object:GetChildren()) do
if v:IsA("Sound") then
continue;
end
v.Position = projectile.Position;
tween_service:Create(v, TweenInfo.new(0.5, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut), {Size = Vector3.new(0, 0, 0)}):Play();
type = not type;
end
task.wait(1);
blast_object:Destroy();
projectile:Destroy();
end
projectile.Touched:Connect(spawn_blast);
Videos on issue:
Working as intended:
Not working as intended (approximately 2 minutes later):
first of all type is a keyword (or were they called differently?) and already taken, its like having a variable called workspace, if you REALLY need it to stay called type, in Python you’d do something like _type, anyways try standing completely still and not even moving your mouse, then see does the behaviour still change
thank you, overlooked the type variable didn’t notice that. No, standing still and not moving the mouse does not fix the issue. Out of interest, why did you think it would?
the client interacting with the projectile, eg they can walk into it (it is common terminology, no?). Also it doesn’t require to be visable.
Also I take back my previous comment, not parenting it to replicated storage does help! Why did you think this would fix the issue?
im sick rn so i mistaked replicated storage for workspace and assumed since workspace has gravity it may change position (somehow?) i have no clue how did i even come up with that… your script is quite messy, I think you should rewrite it. so if you dont want player walking into the rocket you can just rocket.CanCollide = false and leave .CanTouch = true so it still listens for .Touch events but has no collision.
My script is fine for me to work with and i would only do those things if they made a difference to performance or fixed the issue i am currently facing.
Thank you for trying to help but unless you have a thought through suggestion (instead of just “don’t put it in replicated storage” or “don’t move your mouse”) please don’t give anymore.
Could you elaborate on what you are noticing about the tween being “buggy”? I think I see one aspect of the orb model flickering. Have you tried narrowing down the code? Is the buggieness the same every time?
I mean there’s still some thought behind these questions, sometimes the most “random” things seem to fix issues, especially for iteration.
But I agree with TrenchRat, even if you think you know what’s going on, it doesn’t mean you do (hence why there is bugs). Organization is critical the more you program and reduces the amount of time you’ll have to spend debugging.
I also suggest adding comments to your code so both you and people on devforum can get a better idea of your errors and what you seek to fix.
the orb model flickering and falling towards the floor. I don’t know what to focus in on as it only happens 2 or so minutes after the server has began hosting the game. i do not have much experience with the roblox game engine as well so i am asking dev forum, do you have any ideas?
Hone in on the bug by removing all aspects of code and art that are unrelated, to highlight what the bug is and narrow down what might be causing the issue. Along the way of doing this, you might find a logic problem, or find a more telling lead on what is causing the bug.