Scripting a wrecking ball?

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.

2 Likes

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.

1 Like

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.

This could help you:

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)

3 Likes

For some reason when I changed my code to use CFrame like

local TweenService = game:GetService("TweenService")

local mainPart = script.Parent

local goal1 = {}
goal1.CFrame = CFrame.new(Vector3.new(147.735, 61.239, 78.72)) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(-70))

local goal2 = {}
goal2.CFrame = CFrame.new(Vector3.new(147.735, 61.255, 97.636)) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(-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

It started working!

4 Likes