Help Rotate The Part Around The Character Not Working

  1. What do you want to achieve? Rotate The Part Around The Character

  2. What is the issue?
    https://gyazo.com/969bf927a7d6c944a223a3942992c804

  3. What solutions have you tried so far? I searched on devforum but none of them helped

local ts = game:GetService("TweenService")

		local newModel = Instance.new("Model",game.Workspace)


		--
		local newPart = game.ReplicatedStorage.Part:Clone()

		newModel.PrimaryPart = newPart

		newPart.CFrame = char.HumanoidRootPart.CFrame

		newPart.Parent = newModel

		local newWeld = Instance.new("Weld",newPart)

		newWeld.Part0 = newPart
		newWeld.Part1 = char.HumanoidRootPart
		--

		--
		local newCircle = game.ReplicatedStorage.Circle:Clone()

		newCircle.Parent = newModel

		local newWeld2 = Instance.new("Weld",newCircle)

		newWeld2.Part0 = newCircle
		newWeld2.Part1 = newPart
		newWeld2.C0 = CFrame.new(6,0,0)
		--

		--
		local newCircle2 = game.ReplicatedStorage.Circle:Clone()

		newCircle2.Parent = newModel

		local newWeld3 = Instance.new("Weld",newCircle2)

		newWeld3.Part0 = newCircle2
		newWeld3.Part1 = newPart
		newWeld3.C0 = CFrame.new(-6,0,0)
		--

		--
		local newCircle3 = game.ReplicatedStorage.Circle:Clone()

		newCircle3.Parent = newModel

		local newWeld4 = Instance.new("Weld",newCircle3)

		newWeld4.Part0 = newCircle3
		newWeld4.Part1 = newPart
		newWeld4.C0 = CFrame.new(0,0,6)
		--

		--
		local newCircle4 = game.ReplicatedStorage.Circle:Clone()

		newCircle4.Parent = newModel

		local newWeld5 = Instance.new("Weld",newCircle4)

		newWeld5.Part0 = newCircle4
		newWeld5.Part1 = newPart
		newWeld5.C0 = CFrame.new(0,0,-6)
		--




		local info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1, true, 0)
		local TweenProperties = {C0 = CFrame.new(0,0.2,0)}
		local tween = ts:Create(newWeld, info, TweenProperties)

		local info2 = TweenInfo.new(7, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1, false, 0)
		local TweenProperties2 = {Orientation = (newPart.Orientation + Vector3.new(0,360,0))}
		local tween2 = ts:Create(newPart, info2, TweenProperties2)
		tween2:Play()
		tween:Play()
1 Like

Can you try this code. I haven’t tested it though

local DISTANCE_FROM_CHARACTER = 6
local ROTATION_SPEED = 1 -- Set to negative if you want to go backwards
local FOLLOW_SPEED = 5

local run = game:GetService'RunService'
local cos = math.cos
local sin = math.sin

local hrp:Part = char.HumanoidRootPart
local newModel = Instance.new'Model'
local pos = hrp.Position

local vectorX = Vector3.new(DISTANCE_FROM_CHARACTER,0,0)
local vectorZ = Vector3.new(0,0,DISTANCE_FROM_CHARACTER)

local circle:Part = game.ReplicatedStorage.Circle:Clone()
circle.Position = pos*vectorX
circle.Parent = newModel

local circle2:Part = game.ReplicatedStorage.Circle:Clone()
circle2.Position = pos*vectorZ
circle2.Parent = newModel

local circle3:Part = game.ReplicatedStorage.Circle:Clone()
circle3.Position = pos-vectorX
circle3.Parent = newModel

local circle4:Part = game.ReplicatedStorage.Circle:Clone()
circle4.Position = pos-vectorZ
circle4.Parent = newModel

local rotation = 0
newModel.Parent = workspace
run.Heartbeat:Connect(function(dt)
	rotation += dt*ROTATION_SPEED
	pos = pos:Lerp(hrp.Position,dt*FOLLOW_SPEED)
	local sin = sin(rotation)*DISTANCE_FROM_CHARACTER
	local cos = cos(rotation)*DISTANCE_FROM_CHARACTER
	circle.Position  = pos+Vector3.new(sin,0,cos)
	circle2.Position = pos+Vector3.new(cos,0,sin)
	circle3.Position = pos+Vector3.new(-sin,0,-cos)
	circle4.Position = pos+Vector3.new(-cos,0,-sin)
end)

Tell me if there are any errors.

i no using runservice because laggy a tycoon game

RunService is not laggy. The lag depends on how efficient the code is. I ran my code 1000 times per Heatbeat and I was getting ~8ms of lag. I also ran it 10 000 times per Heartbeat and I was getting ~40ms of lag. I don’t know how many you will run it but I’m pretty sure it’s not more than 1000.

not worked .-…-.-…-.–.-.-…-.-.-

Are there any errors that appeared in the output?

no have errors in output.-.-.-.-.-.-.

What do you mean by not worked? Like you did not see the spheres rotating around the character?

all i want is a constantly rotating part with weld to the character’s humanoidrootpart

You are changing the sin & cos function reference to a number

exactly, then i use the new sin&cos here:

Those are the values, not the function. If it was the function, it would have errored.

I could have renamed that to avoid confusion.

1 Like

I see, its only changing the sin & cos in the hearbeat scope

you could make it so it always faces the player with

while wait() do
Part.CFrame = CFrame.new(Part.CFrame , Character.Torso.CFrame)
--code to make it go to the left of its look vector
end

and than make it go to the left of its look vector and it should always turn around since the rotation would change

all i want is a constantly rotating part with weld to the character’s humanoidrootpart

oh than u could just have 3 parts rig 1 main part 1 supportiv part which is in main part and the rotating part which is rigged to supportiv part and just do how fast u want the part to spin ussing animator with supportiv part and make it have its own humanoid and u will just need to make it so the 3 part model is unanchored and it loads the animation and so it just welds main part with the humanoidrootpart in humanoid root parts position(sorry if its hard to understand i could make simple demo to show what i mean)

why are you talking so long all i want is a piece that revolves around itself and weld to the character

i tried to explain it as clear as possible since the idea about making it spin ussing look vector wasn’t great one in ur opinion