I made a fireball ability that causes damage on Touched:Connect, it worked before when i was using Body velocity but i reworked the script to make it a tween instead but now the damage and effects dont work
local rp = game:GetService("ReplicatedStorage")
local Fireball = rp:WaitForChild("Events"):WaitForChild("Fire"):WaitForChild("FireBall")
local Animations = script:WaitForChild("Animations")
local Meshes = script:WaitForChild("Meshes")
local Debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
local speed = script:GetAttribute("Speed")
local Damage = script:GetAttribute("Damage")
Fireball.OnServerEvent:Connect(function(Player,direction)
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local humrp = Character:WaitForChild("HumanoidRootPart")
local effectsFold = Instance.new("Folder",workspace)
effectsFold.Name = Player.Name.." Effects"
Debris:AddItem(effectsFold,6)
local FB = Meshes:WaitForChild("FireBall"):Clone()
FB.CFrame = humrp.CFrame * CFrame.new(0,0,-3)
FB.Orientation = FB.Orientation + Vector3.new(0,0,0)
FB.Parent = effectsFold
local FBgoal = TweenService:Create(FB,TweenInfo.new(4),{CFrame = FB.CFrame * CFrame.new(0,0,-200)})
FBgoal:Play()
FB.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Character) then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
if Humanoid.Health > 0 then
effectsFold:Destroy()
Humanoid:TakeDamage(Damage)
local explodeFold = Instance.new("Folder",workspace)
explodeFold.Name = Player.Name.." Explode"
Debris:AddItem(explodeFold,1.5)
local explode = Meshes:WaitForChild("FireBallExplode"):Clone()
explode.Size = Vector3.new(1,1,1)
explode.CFrame = CFrame.new(Hit.CFrame.p,humrp.CFrame.p)
explode.Parent = explodeFold
local ring = Meshes:WaitForChild("Ring"):Clone()
ring.Orientation = Vector3.new(-35,90,0)
ring.Size = Vector3.new(2.5,0.15,2.5)
ring.CFrame = explode.CFrame
ring.Parent = explodeFold
local ringtwo = Meshes:WaitForChild("RingTwo"):Clone()
ringtwo.Orientation = Vector3.new(35,90,0)
ringtwo.Size = Vector3.new(2.5,0.15,2.5)
ringtwo.CFrame = explode.CFrame
ringtwo.Parent = explodeFold
local flare = Meshes:WaitForChild("Flare"):Clone()
flare.Size = Vector3.new(1.154, 1.154, 1.154)
flare.CFrame = explode.CFrame
flare.Parent = explodeFold
local Egoal = {}
Egoal.Size = explode.Size + Vector3.new(20,20,20)
local Einfo = TweenInfo.new(1)
local Etween = TweenService:Create(explode,Einfo,Egoal)
Etween:Play()
local Rgoal = {}
Rgoal.Size = ring.Size + Vector3.new(90,0.15,90)
local Rinfo = TweenInfo.new(2)
local Rtween = TweenService:Create(ring,Rinfo,Rgoal)
Rtween:Play()
local RRgoal = {}
RRgoal.Size = ringtwo.Size + Vector3.new(90,0.15,90)
local RRinfo = TweenInfo.new(2)
local RRtween = TweenService:Create(ringtwo,RRinfo,RRgoal)
RRtween:Play()
local Fgoal = {}
Fgoal.Size = flare.Size + Vector3.new(21,21,21)
local Finfo = TweenInfo.new(1)
local Ftween = TweenService:Create(flare,Finfo,Fgoal)
Ftween:Play()
local Frot = {}
Frot.Orientation = flare.Orientation + Vector3.new(0,1000,0)
local Frotinfo = TweenInfo.new(5)
local Frottween = TweenService:Create(flare,Frotinfo,Frot)
Frottween:Play()
local Rrot = {}
Rrot.Orientation = ring.Orientation + Vector3.new(-35,90,0)
local Rrotinfo = TweenInfo.new(0.1)
local Rrittween = TweenService:Create(ring,Rrotinfo,Rrot)
Rrittween:Play()
local RRrot = {}
RRrot.Orientation = ringtwo.Orientation + Vector3.new(35,90,0)
local RRrotinfo = TweenInfo.new(0.1)
local RRrittween = TweenService:Create(ringtwo,RRrotinfo,RRrot)
RRrittween:Play()
wait(0.5)
for i, v in pairs(explodeFold:GetChildren()) do
local goal = {}
goal.Transparency = v.Transparency + (1 - v.Transparency)
local info = TweenInfo.new(1)
local tween = TweenService:Create(v,info,goal)
tween:Play()
end
end
else
local tempCFrame = FB.CFrame
effectsFold:Destroy()
local explodeFold = Instance.new("Folder",workspace)
explodeFold.Name = Player.Name.." Explode"
Debris:AddItem(explodeFold,1.5)
local explode = Meshes:WaitForChild("FireBallExplode"):Clone()
explode.Size = Vector3.new(1,1,1)
explode.CFrame = CFrame.new(tempCFrame.p,humrp.CFrame.p)
explode.Parent = explodeFold
local ring = Meshes:WaitForChild("Ring"):Clone()
ring.Orientation = Vector3.new(-35,90,0)
ring.Size = Vector3.new(2.5,0.15,2.5)
ring.CFrame = explode.CFrame
ring.Parent = explodeFold
local ringtwo = Meshes:WaitForChild("RingTwo"):Clone()
ringtwo.Orientation = Vector3.new(35,90,0)
ringtwo.Size = Vector3.new(2.5,0.15,2.5)
ringtwo.CFrame = explode.CFrame
ringtwo.Parent = explodeFold
local flare = Meshes:WaitForChild("Flare"):Clone()
flare.Size = Vector3.new(1.154, 1.154, 1.154)
flare.CFrame = explode.CFrame
flare.Parent = explodeFold
local Egoal = {}
Egoal.Size = explode.Size + Vector3.new(20,20,20)
local Einfo = TweenInfo.new(1)
local Etween = TweenService:Create(explode,Einfo,Egoal)
Etween:Play()
local Rgoal = {}
Rgoal.Size = ring.Size + Vector3.new(90,0.15,90)
local Rinfo = TweenInfo.new(2)
local Rtween = TweenService:Create(ring,Rinfo,Rgoal)
Rtween:Play()
local RRgoal = {}
RRgoal.Size = ringtwo.Size + Vector3.new(90,0.15,90)
local RRinfo = TweenInfo.new(2)
local RRtween = TweenService:Create(ringtwo,RRinfo,RRgoal)
RRtween:Play()
local Fgoal = {}
Fgoal.Size = flare.Size + Vector3.new(21,21,21)
local Finfo = TweenInfo.new(1)
local Ftween = TweenService:Create(flare,Finfo,Fgoal)
Ftween:Play()
local Rrot = {}
Rrot.Orientation = ring.Orientation + Vector3.new(-35,90,0)
local Rrotinfo = TweenInfo.new(0.1)
local Rrittween = TweenService:Create(ring,Rrotinfo,Rrot)
Rrittween:Play()
local RRrot = {}
RRrot.Orientation = ringtwo.Orientation + Vector3.new(35,90,0)
local RRrotinfo = TweenInfo.new(0.1)
local RRrittween = TweenService:Create(ringtwo,RRrotinfo,RRrot)
RRrittween:Play()
local Frot = {}
Frot.Orientation = flare.Orientation + Vector3.new(0,1000,0)
local Frotinfo = TweenInfo.new(5)
local Frottween = TweenService:Create(flare,Frotinfo,Frot)
Frottween:Play()
wait(0.5)
for i, v in pairs(explodeFold:GetChildren()) do
local goal = {}
goal.Transparency = v.Transparency + (1 - v.Transparency)
local info = TweenInfo.new(1)
local tween = TweenService:Create(v,info,goal)
tween:Play()
end
end
end
end
end)
end)

1 comment
Likely because it's anchored, not gonna read the script but, Touched doesn't work on 2 anchored parts. Use the solution by potato