Replicating Rotating Parts

Hi, im trying replicate a smooth rotating part across all clients
i have tried doing this but it doesnt work

	if (is_type) == "automatic" then
			if not (is_active) then

				if not (spin:GetAttribute("active")) then
					sound:Play()
					spin:SetAttribute("active", true)
				end

				spin:SetAttribute("rotate", spin:GetAttribute("rotate") + 0.1)
			else
				if (spin:GetAttribute("active")) then
					sound:Stop()
					stop:Play()

					spin:SetAttribute("active", nil)
				end
			end
		end

this is in a while true loop on the server


function ClientTween:logic()
    for _, spin in pairs(Spins) do
        local rotate = spin:GetAttribute("rotate")

        spin:GetAttributeChangedSignal("rotate"):Connect(function(n)
            local rotate = spin:GetAttribute("rotate")

            if (rotate) then
				TweenService:Create(spin, info, {Orientation = Vector3.new(0, rotate, 0)}):Play()
            end
        end)

		if (rotate) then
			TweenService:Create(spin, info, {Orientation = Vector3.new(0, rotate, 0)}):Play()
        end
    end
end

client code

1 Like

1 Like

This may be related to the Orientation property acting up. Try using CFrame instead:

local cf = CFrame.new(spin.Position)*CFrame.Angles(0, math.rad(rotate), 0)
TweenService:Create(spin, info, {CFrame = cf}):Play()
1 Like

local TweenService = game:GetService("TweenService")
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Koat = require(ReplicatedStorage:WaitForChild("Koat"))

local SpringMotion = Koat:LoadUtility("SpringMotion")

local Spins = CollectionService:GetTagged("Spins")

local info = TweenInfo.new(1)

local ClientTween = {}

function ClientTween:logic()
    for _, spin in pairs(Spins) do
		local rotate = spin:GetAttribute("rotate")
		
		if (rotate) then
			local cf = CFrame.new(spin.Position )*CFrame.Angles(0, math.rad(rotate), 0)

			TweenService:Create(spin, info, {CFrame = cf}):Play()
		end
		
		spin:GetAttributeChangedSignal("rotate"):Connect(function(n)
			local rotate = spin:GetAttribute("rotate")
			local cf = CFrame.new(spin.Position )*CFrame.Angles(0, math.rad(rotate), 0)

			TweenService:Create(spin, info, {CFrame = cf}):Play()
		end)
    end
end


function ClientTween:new()
    self:logic()
end

function ClientTween:Init()
    self:new()
end
return ClientTween

Try storing the tweens and canceling them before starting new ones.