Some parts is not following with the part of the pendulum, how I solve this?

I was making a blade pendulum for a update of my game, but there are some parts that just stop following the base part of the pendulum, I have made this script for the model:

local base = script.Parent.Base
local arm = script.Parent.Arm
local blade = script.Parent:WaitForChild("Blade")

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local swing = {
	CFrame = base.CFrame * CFrame.Angles(math.rad(25), 0, 0)
}
local swing2 = {
	CFrame = base.CFrame * CFrame.Angles(-math.rad(25), 0, 0)
}

local tween = tweenService:Create(base, tweenInfo, swing)
local tween2 = tweenService:Create(base, tweenInfo, swing2)

while wait() do
	tween:Play()
	tween.Completed:Wait()
	tween2:Play()
	tween2.Completed:Wait()
end

And here is the example of what is happening:

well for one, i’d scrap the code and just use a physics constraint and allow the weight of the pendulum to swing itself or a similar solution.

but, you’re already here and thats okay. so here:

  1. get rid of swing2 and tween2 u dont need it. instead just set the pendulum to the starting position of -25 degrees
  2. make tweenInfo this:
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true)

the parameter after easingDirection is repeatCount, setting it to -1 means the tween will repeat forever. then, setting the reverse parameter after that to true means itll swing back to the start before repeating.

1 Like