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:
https://gyazo.com/00c1e32b9e065e2b6584a8416c39d8cd
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
end
end)
end)
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