Fireball doesn't correctly move towards the mouse

Hello there!

So there is an issue with one of the ability of a sword I’m currently making. Said ability is a simple fireball ability. The issue however is that the fireball seems to move towards the mouse but not as I wanted it to as seen in the video below:

If you haven’t spot it, then here’s a diagram of what’s happening.


What I’m trying to do is make the fireball act as a generic projectile in any 2D game although when I test it, it will shrink because it’s actually doing moving further away from the player.

local FireBallAnim = Humanoid.Animator:LoadAnimation(Tool.FireballSummon)
		FireBallAnim:Play()
		
		FireBallAnim:GetMarkerReachedSignal("SummonFireBall"):Connect(function()
			local FireBall = Instance.new("Part",workspace)
			FireBall.CFrame = plr.Character["Left Arm"].CFrame + Vector3.new(0,-2,0)
			FireBall.Shape = Enum.PartType.Ball
			FireBall.Material = Enum.Material.Neon
			FireBall.BrickColor = BrickColor.new("Neon orange")
			FireBall.Size = Vector3.new(0.1,0.1,0.1)
			FireBall.CanCollide = false
			
			local WeldContraint = Instance.new("WeldConstraint",FireBall)
			WeldContraint.Part0 = FireBall
			WeldContraint.Part1 = plr.Character["Left Arm"]
			
			--//Tweening
			local Tweeninfo = TweenInfo.new(
				.50,
				Enum.EasingStyle.Sine,
				Enum.EasingDirection.Out
			)
			local Tween = game:GetService("TweenService"):Create(FireBall,Tweeninfo,{Size = Vector3.new(2,2,2)})
			Tween:Play()
			
			FireBallAnim:GetMarkerReachedSignal("ThrowFireBal"):Connect(function()
				WeldContraint:Destroy()
				FireBall.Anchored = true
				
				local Tweeninfo = TweenInfo.new(
					3,
					Enum.EasingStyle.Sine,
					Enum.EasingDirection.Out
				)
				local Tween = game:GetService("TweenService"):Create(FireBall,Tweeninfo,{Position = MousePos})
				Tween:Play()
				Tween.Completed:Wait()
				FireBall:Destroy()
			end)
1 Like

Are you using the 3D position of the mouse rather than its 2D counterpart?
mouse.X, mouse.Y

1 Like

Oh seems like it, thanks! But how can I implimate it?

2 Likes

You could probably just use Vector2 instead of Vector3 for the position of the mouse (in your script mentioned as MousePos presumably). You can find all information regarding that in the documentation provided by D4rk.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.