Tween is Spazzing out

Hello, I am trying to tween the position of a fire ball so that it moves in the direction that the camera is facing, however for what ever reason the tween starts glitching as it moves – can someone please tell me how to fix this?
Here is my script:

local function shoot_blast()
		
		local blast_info = TweenInfo.new(
			3,
			Enum.EasingStyle.Quint,
			Enum.EasingDirection.Out,
			0,
			false,
			0
		)
		
		local goals = {
			Position = hrp.Position + lookVector.Unit*200
		}
		
		local tween = TweenService:Create(blast_clone, blast_info, goals)
		
		tween:Play()
	end

Here is a video of what’s happening:

2 Likes

hmm. maybe the goal is being altered by another script? check the goal position using the print() function. if the value doesnt change while the glitching, its a tween problem, if it does, then its probably being altered by another script, or by different parts of the same script. i tried to reproduce the problem on my client, but the tween seems to be working fine

Anchor your fireball, its not anchored thats why its falling down.

Fixed code (If needed)
local function shoot_blast()

		blast_clone.Anchored = true -- this line we've added.

		local blast_info = TweenInfo.new(
			3,
			Enum.EasingStyle.Quint,
			Enum.EasingDirection.Out,
			0,
			false,
			0
		)
		
		local goals = {
			Position = hrp.Position + lookVector.Unit*200
		}
		
		local tween = TweenService:Create(blast_clone, blast_info, goals)
		
		tween:Play()
	end
1 Like

Like said above, tweens can get haywire if you don’t anchor your targeted part

That works, however the Touched() function isn’t registering when I have it anchored for some reason. Here is the entire script:

local rs = game.ReplicatedStorage
local fire_blast = rs:WaitForChild("fireblast")
local blast = rs:WaitForChild("blast")

local TweenService = game:GetService("TweenService")

fire_blast.OnServerEvent:Connect(function(player, lookVector)
	local char = player.Character
	local blast_clone = blast:Clone()
	local hrp = char:WaitForChild("HumanoidRootPart")
	--local lookVector = hrp.CFrame.LookVector (if I want it to be based on where the player is facing instead of camera)

	--- try tweening blast
	
	hrp.Anchored = true
	
	local function blast_startup()

		local blast_info = TweenInfo.new(
			1, --duration
			Enum.EasingStyle.Elastic,
			Enum.EasingDirection.Out,
			0, -- number of repeats
			false,
			0 -- delay
		)

		local goals = {
			Size = Vector3.new(5,5,5);
			Transparency = 0
		}

		local tween = TweenService:Create(blast_clone, blast_info, goals)

		tween:Play()
	end
	
	local function shoot_blast()
		
		local blast_info = TweenInfo.new(
			3,
			Enum.EasingStyle.Quint,
			Enum.EasingDirection.Out,
			0,
			false,
			0
		)
		
		local goals = {
			CFrame = CFrame.new(hrp.Position + lookVector.Unit*200)
		}
		
		local tween = TweenService:Create(blast_clone, blast_info, goals)
		
		tween:Play()
	end
	
	local function blast_exit()

		local blast_info = TweenInfo.new(
			1, --duration
			Enum.EasingStyle.Elastic,
			Enum.EasingDirection.In,
			0, -- number of repeats
			false,
			0 -- delay
		)

		local goals = {
			Size = Vector3.new(1,1,1);
			Transparency = 1
		}

		local tween = TweenService:Create(blast_clone, blast_info, goals)

		tween:Play()
	end

	blast_clone.Parent = game.Workspace
	blast_clone.Position = hrp.Position + lookVector*10
	blast_clone.CanCollide = false

	local at = Instance.new("Attachment", blast_clone)
	at.Name = "Attachment0"
	at.Position = Vector3.new(0,0,0)
	

	blast_clone.Anchored = true
	blast_startup()
	wait(1)
	shoot_blast()
	hrp.Anchored = false
	

	blast_clone.Touched:Connect(function(hit)
		print("Touched")
	end)

	wait(2)
	if blast_clone then
		blast_exit()
		wait(1)
		blast_clone:Destroy()
	end
end)

If it is not anchored, the Touched() function works normally, but if it is then nothing happens and it just phases right through objects without the Touched() registering.

Make sure CanTouch is set to true. (checked)
image

and since its a fireball, make can collide to false (unchecked)
image

This is how it looks:
image

Apparently the problem is with Roblox’s physics engine. For what ever reason, while tweens are anchored and moving their .Touched() stops working – I don’t know why Roblox thought that was a good idea, but they did.

Although it may not be the most efficient fix, I found that continuously utilizing :GetTouchingParts() then using a nested pairs loop while the tween is in motion works best.

1 Like