Why is my burst tween soo inconsistent?

  1. What do you want to achieve? Trying to make the tween play every second for the robbery icons.

  2. What is the issue? The issue is that the tween doesn’t play every second! sometimes the tween plays once or twice then stops then play again but doesn’t play the tween every second.

  3. What solutions have you tried so far? I tryed to change the code to for i loops but it still doesn’t play the tween every second. I spent weeks trying to make it consistent and still haven’t found why it does this.

Can someone tell me why the tween doesn’t play every second or skips the tween?

game:GetService("RunService").Heartbeat:Connect(function()
	for i,Stat in pairs(Markers) do
		local Marker = Stat[1]
		local Location = Stat[2]
		Marker.Visible = Location.Config.Enabled.Value
		
		if Location.Config.Enabled.Value then
			local MarkerPosition , MarkerVisible = game.Workspace.CurrentCamera:WorldToScreenPoint(Location.Position)
			local MarkerRotation = game.Workspace.CurrentCamera.CFrame:Inverse()*Location.CFrame
			local MarkerAbsolute = Marker.AbsoluteSize
			
			local MarkerPositionX = MarkerPosition.X - MarkerAbsolute.X/2
			local MarkerPositionY = MarkerPosition.Y - MarkerAbsolute.Y/2
			
			if MarkerPosition.Z < 0  then
				MarkerPositionX,MarkerPositionY = ClampMarkerToBorder(MarkerPositionX,MarkerPositionY,MarkerAbsolute)
			else
				if MarkerPositionX < 0 then
					MarkerPositionX = 0
				elseif MarkerPositionX > (Screen.X - MarkerAbsolute.X) then
					MarkerPositionX = Screen.X - MarkerAbsolute.X
				end
				if MarkerPositionY < 0 then
					MarkerPositionY = 0
				elseif MarkerPositionY > (Screen.Y - MarkerAbsolute.Y) then
					MarkerPositionY = Screen.Y - MarkerAbsolute.Y
				end
			end
			
			CheckPlayerLastRobbery()
				
			Marker.RotateLabel.Visible = not MarkerVisible
			Marker.RotateLabel.Rotation = 90 + math.deg(math.atan2(MarkerRotation.Z,MarkerRotation.X))
			Marker.Position = UDim2.new(0,MarkerPositionX,0,MarkerPositionY)
			
			T:Create(Marker,TweenInfo.new(.5),{ImageColor3 = Location.Config.MarkerColor.Value}):Play()
			T:Create(Marker.RotateLabel.Arrow,TweenInfo.new(.5),{ImageColor3 = Location.Config.MarkerColor.Value}):Play()

             -- Something in this code is making the tween not play every second or skipping Idk
			local CurrentTime = tick()	
		if Location.Config.BurstType.Value == "Criminal" then
			if math.floor((CurrentTime%2)*100)/100 <= .01 then
				local Burst = script.BurstRings:Clone()
				Burst.ImageColor3 = Color3.fromRGB(255,89,89)
				Burst.Parent = Marker
				T:Create(Burst,TweenInfo.new(1),{Size = UDim2.new(1.8,0,1.8,0),ImageTransparency = 1}):Play()
				game.Debris:AddItem(Burst,1)
			elseif math.floor((CurrentTime%1)*100)/100 <= .01 then
				local Burst = script.BurstRings:Clone()
				Burst.ImageColor3 = Color3.fromRGB(255,89,89)
				Burst.Parent = Marker
				T:Create(Burst,TweenInfo.new(1),{Size = UDim2.new(1.8,0,1.8,0),ImageTransparency = 1}):Play()
				game.Debris:AddItem(Burst,1)		
			end				
		    elseif Location.Config.BurstType.Value == "Police" then
				if math.floor((CurrentTime%2)*100)/100 <= .01 then
					local Burst = script.BurstRings:Clone()
					Burst.ImageColor3 = Color3.fromRGB(82,124,174)
					Burst.Parent = Marker
					T:Create(Burst,TweenInfo.new(1),{Size = UDim2.new(1.8,0,1.8,0),ImageTransparency = 1}):Play()
					game.Debris:AddItem(Burst,1)
			    elseif math.floor((CurrentTime%1)*100)/100 <= .01 then
					local Burst = script.BurstRings:Clone()
					Burst.ImageColor3 = Color3.fromRGB(255,89,89)
					Burst.Parent = Marker
					T:Create(Burst,TweenInfo.new(1),{Size = UDim2.new(1.8,0,1.8,0),ImageTransparency = 1}):Play()
					game.Debris:AddItem(Burst,1)
				end	
		    end
		end
	end
end)

Some please reply!

I believe your issue comes from the fact you are connectiong a Heartbeat event. Heartbeat is variable freqeuncy, so the performance of the machine will affect the time due to frame drops and what not. I recommend Runservice.RenderStepped instead.That way, the function can fire before the frame is completed and not after the frame simulates. You can read more about this in the wiki.

1 Like