I’m trying to make a part follow a route using a tweening script, but some custom effects glitch out with this. I do know the problem, but I have no clue how to fix it. Inside the part I’m trying to tween is a script which creates some waving effects on the part along with the roblox water waves. This script constantly updates the Y-Axis using a loop of:
game:GetService("RunService").Heartbeat:Connect(function(p1)
Now the tweening script updates every 1 second:
local TweeningInformation = TweenInfo.new(
waitingtime,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local Props = {
CFrame = CFrame.new(
Vector3.new(
v.CFrame.X,
script.Parent.CFrame.Y,
v.CFrame.Z))
}
local Tweenservice = game:GetService("TweenService")
local Movement = Tweenservice:Create(script.Parent,TweeningInformation,Props)
Movement:Play()
“waitingtime” is standard 1 second. So every 1 second, it tweens to another part. But the issue with this is that for the CFraming, I’ll have to include the Y axis. Which only updates the tween every 1 second resulting in a ugly tweening. The Y axis of the waving script gets updated every frame, but this script only does that once per second. The waving works normal if I disable the tweening script:
https://gyazo.com/393402cd3fab2aa452864722a742a23b
But whenever I re-enable it, this is the result:
https://gyazo.com/fb4b33839b7ada6642c08e7bba3d5372
Does anyone know how I can bypass this, or possibly use an alternative of tweening which updates the Y-axis at every frame?
EDIT: This is the CFraming inside the waving script. “c” is returned from a function which makes a calculation on the exact wave height and speed of the part’s position.
local APP = CFrame.new (
script.Parent.CFrame.X,
c/(script._CNF._APlX.Value),
script.Parent.CFrame.Z
)
--print(APP)
script.Parent.CFrame = APP