So I’ve been messing around with tween loops and the likes and I have come across an issue where the tween is crazy jittery, now part of me thinks this is the loop that is part of the issue but I want some insight on what some others think about it and what could possibly be better for this.
runService.Heartbeat:Connect(function()
if buttonDown and values.barrel.Value == true and values.ammunition.Value >= 0 and values.reloading.Value == false then
if uis.KeyboardEnabled then
local mousePos = mouse.Hit.Position
remoteEvents.fired:FireServer(mousePos, buttonDown)
if values.capturable.Value == false then
values.ammunition.Value = values.ammunition.Value - 1
end
end
local serverStream = game.Workspace.StreamData:WaitForChild(player.Name)
if serverStream then
if streamEffect == nil then
serverStream.Transparency = 1
for i,v in pairs(serverStream.Electricity:GetChildren()) do
v.Enabled = false
end
streamEffect = game.ReplicatedStorage.Equipment.FX.Stream:Clone()
streamEffect.Parent = game.Workspace.StreamData
streamEffect.Name = "clientStream"
else
local math1 = values.tweenPositions.mathValue1.Value
local math2 = values.tweenPositions.mathValue2.Value
streamEffect.CFrame = CFrame.lookAt((game.Workspace.StreamData:WaitForChild("Part").Position + tool.Handle.Tip.Position)/2, game.Workspace.StreamData:WaitForChild("Part").Position, Vector3.yAxis) * CFrame.Angles(0, math.rad(90),0)
streamEffect.Startpoint.WorldPosition = tool.Handle.Tip.Position
streamEffect.Endpoint.WorldPosition = game.Workspace.StreamData:WaitForChild("Part").Position
local properties1 = {
["WorldPosition"] = ((streamEffect.Startpoint.WorldPosition + streamEffect.Segment2.WorldPosition) / 2) + Vector3.new(math.random(math1, math2), math.random(math1, math2), math.random(math1, math2))
}
local properties2 = {
["WorldPosition"] = ((streamEffect.Segment1.WorldPosition + streamEffect.Segment3.WorldPosition) / 2) + Vector3.new(math.random(math1, math2), math.random(math1, math2), math.random(math1, math2))
}
local properties3 = {
["WorldPosition"] = ((streamEffect.Segment2.WorldPosition + streamEffect.Endpoint.WorldPosition) / 2) + Vector3.new(math.random(math1, math2), math.random(math1, math2), math.random(math1, math2))
}
local tween1 = tweenService:Create(game.Workspace.StreamData:WaitForChild("clientStream").Segment1, tweenInfo, properties1)
local tween2 = tweenService:Create(game.Workspace.StreamData:WaitForChild("clientStream").Segment2, tweenInfo, properties2)
local tween3 = tweenService:Create(game.Workspace.StreamData:WaitForChild("clientStream").Segment3, tweenInfo, properties3)
tween1:Play()
tween2:Play()
tween3:Play()
end
end
end
end)
Specifically bottom after the else is where the tween stuff happens and here is what my tweenInfo looks like followed by a video of what is going on:
local tweenInfo = TweenInfo.new(
0.4,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true,
0
)
Any help to point me in the right direction will be greatly appreciated. Thank you to whoever responds in advance!