So, I’ve made a fireball. How would I go on making it explode. For example when it touches someone(Which I did) it will get larger using Tween Service. I tried doing it, but it wouldn’t tween with no errors. Since it doesn’t work and I have barely understanding of what to do I want to start from scratch.
Maybe something like this:
Like @MediaHQ said, tween the size using TweenService. You can also have a loop like this (which doesn’t yield the script at all, so both the loop and the tween happen simultaneously).
spawn(function()
for i = 1, 100 do
wait(0.01)
Fireball.Transparency = Fireball.Transparency + 0.01
end
Fireball:Destroy()
end)
That script will cause the fireball (which is indexed as Fireball in the script above) to slowly become more transparent until you cannot see it then it will destroy the fireball. Once again, use TweenService to tween the fireball size then use the function above right after the :Play() for the tween.
The script below should work for your fireball, I just recommend making your fireball a sphere.
local ts = game:GetService("TweenService");
local collision = false -- set to true if you want the fireball to be collision-able
local seconds = 1; -- replace with how long should the tween be, such as 2 seconds or 0.5 seconds
local objecttotween = Fireball; -- Make a variable called Fireball which indexes the actual fireball
local tsinfo = TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingStyle.In);
local goal = {Size = Vector3.new(2, 2, 2)}; -- replace the numbers in the Vector3.new() with how big should the fireball be in the end
local tweenanim = ts:Create(objecttotween, tsinfo, goal);
Fireball.Touched:Connect(function(h)
if h:IsA("Mesh") or h:IsA("BasePart") or h:IsA("Model") or h:IsA("Part") or h:IsA("Union") then
tweenanim:Play()
spawn(function()
if collision then
Fireball.CanCollide = true
else
Fireball.CanCollide = false
end
for i = 1, 100 do
wait(0.01)
Fireball.Transparency = Fireball.Transparency + 0.01
end
Fireball:Destroy()
end)
end)