Explosion not working

Explosion not working, ends up making a mess instead

Im a beginner scripter, and I was trying to use remote events as i recently learned how to use them. I wanted to make a Fireball which will explode if it touches a part. It does work, but it ends up creating multiple fireballs and makes my PC lag ALOT.

Here is what ends up happening:


Here is a screenshot of the Explorer:

Here is what comes in the output:

The script:

local player = game.Players.LocalPlayer --Gets the player i think?

local RepStorage = game:GetService("ReplicatedStorage")-- Gets the replicatedStorage, pretty sure
local FireballSummon = RepStorage:WaitForChild("FireballSummon") --Gets the event

local ServerStorage = game:GetService("ServerStorage") -- Gets serverStorage
local Fireball = ServerStorage:WaitForChild("Fireball") --Gets the Fireball so i can use it now
local Explosion = ServerStorage:WaitForChild("Explosion") -- Gets the exploion so i can use it later

RepStorage.FireballSummon.OnServerEvent:Connect(function(player) -- calls a function 
	local character = player.character -- gets the character of the player
	local HumanoidRootPart= character:WaitForChild("HumanoidRootPart") -- character waits for its child, the Humanoid root part 
	local makeFireball = game.ServerStorage.Fireball:Clone() -- Clones the Fireball from server storage
	makeFireball.CFrame = character.HumanoidRootPart.CFrame -- sets the poition of the Fireball to the players position
	local BV = Instance.new("BodyVelocity") -- Creates body velocity so the fireball goes whoooosh
	BV.MaxForce = Vector3.new(6000,6000,6000) -- SPEEEEEEED
	BV.Velocity = (character.HumanoidRootPart.CFrame.lookVector*90) -- direction?
	BV.Parent = makeFireball -- Parents the bodyvelocity to the fireball
	makeFireball.Parent = workspace -- parents the fireball to the qorkspace so everyone can see it
	makeFireball.Touched:Connect(function(hit) -- another function for the explosion 
		if hit.Parent:FindFirstChild("BreakPart") then -- Finds the part which will make the firebll explode if the fireball touches the part
			local newExplosion = game.ServerStorage.Explosion:Clone() -- Clones the explosion
			newExplosion.CFrame = makeFireball.CFrame -- Sets the position of the explosion to the position of the fireball
			newExplosion.Parent = workspace -- Parents the explosion to the workspace so that everyone can see it
			local TweenService = game:GetService("TweenService") -- tweenservice is ready to go to make the explosion BIGG
			local Info = TweenInfo.new(  -- All the info (I always forget it lol)
				1.5, -- idk wth this is ik its just used so yeah
				Enum.EasingStyle.Elastic, --Style of the tween (linear wouldnt look good in an explosion) 
				Enum.EasingDirection.Out, -- direction is out o the sphere can grow big
				0, -- i guess this repeats it??
				false, -- idk
				0 -- amount of time it has to be repeated?
			local EndInfo = { -- a table
				Vector3.new(10,10,10) -- Size
			local explosionTween = TweenService:Create(newExplosion, Info, EndInfo) -- makes the tween
			explosionTween:Play() -- Plays the tween

All that code is in a script which is in the ServerScriptService.
The input is working perfectly, but the explosion isnt working.

Im a beginner scripter who started learning a week ago, so I dont know if I made a simple mistake,
I hope you can help :slight_smile:

What is line 47? I really don’t want to count lines. Also add debounce:

    if debounce = false
        debounce = true
        -- do stuff
        debounce = false

local explosionTween = TweenService:Create(newExplosion, Info, EndInfo) – makes the tween

local EndInfo = { -- a table
	Vector3.new(10,10,10) -- Size

That’s not how you make the goals for a tween, maybe try

local EndInfo = { -- a table
	Size = Vector3.new(10,10,10) -- Size

First, the 1.5 is how long the tween is, the 0 is how many times it should repeat, the false means if it reverses after the tween is done playing, and the last 0 is the delay time.

Its still not working, here is what ends up happening:


Thanks for the help! I’ll remember it next time :slight_smile: , but idk what to do about the problem

1 Like

You don’t have a debounce for the Touched event, that’s why it’s getting ran a lot. You need a debounce or checks to see if what is touching it is a fireball or not. Anything is going to cause it to make another fire ball

1 Like

That’s probably just because it fires multiple times per touch, add debounce.

You should add a debounce like how @Pokemoncraft5290 said.

Oh okay! Thanks alot for the help!

1 Like