I need to script a wrecking ball for a map built by my friend.
The rope moves but the wrecking ball and the spikes don’t move with it. The rope is anchored. The ball and spikes aren’t anchored but they are welded to the rope so they should move with the rope.
Here is my code (it’s in a script parented to the rope part which is named “MainPart”):
local TweenService = game:GetService("TweenService")
local mainPart = script.Parent
local goal1 = {}
goal1.Position = Vector3.new(147.735, 61.239, 78.72)
goal1.Orientation = Vector3.new(0, 90, -70)
local goal2 = {}
goal2.Position = Vector3.new(147.735, 61.255, 97.636)
goal2.Orientation = Vector3.new(0, 90, -115)
local tweenInfo = TweenInfo.new(2)
local tween
while true do
tween = TweenService:Create(mainPart, tweenInfo, goal1)
tween:Play()
tween.Completed:Wait()
tween = TweenService:Create(mainPart, tweenInfo, goal2)
tween:Play()
tween.Completed:Wait()
end
I have tried searching here on DevForum but I have found nothing that would help me.
TweenService sets the position value directly, which will break the weld. If you wanted the weld solution to work, you would have to use a BodyMover and not TweenService.
BodyMovers don’t work when the part is anchored. If I unanchor the part the whole wrecking ball falls into lava, it doesn’t hang from the cave ceiling.
I know somebody who created a swinging ball using this tutorial. You can create a part as a pivot which then tweens both the wrecking ball and the rope (as long as they are in the same model)