I first tried with a hinge constraint but due to the client and server’s discrepancy, the line would kill the player even without touching it… Now I made a CFrame updating with the while do iteration but it seems choppy.
I’ve been thinking if it was a better solution to use an hinge constraint but let the touched event get called from the HumanoidRootPart instead from the bar?
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
No not really, I am trying with a CFrame but it looks choppy…
local players = game:GetService("Players")
local runService = game:GetService("RunService")
local part: BasePart = nil -- your spinner
local state = false
local speed = 10
type void = nil
local function start(): void
if not state then
state = true
local nextCFrame = part.CFrame * CFrame.Angles(0, math.rad(5), 0)
local connection; connection = runService.PostSimulation:Connect(function(dt)
if state then
nextCFrame = part.CFrame * CFrame.Angles(0, math.rad(5), 0)
part.CFrame = part.CFrame:Lerp(nextCFrame, dt * speed)
elseif part.CFrame == nextCFrame then
connection:Disconnect()
else
part.CFrame = part.CFrame:Lerp(nextCFrame, dt * speed / 2)
end
end)
end
end
local function stop(): void
if state then
state = false
end
end
start()
use start() and stop() functions to interact with ur spinner
Yes, you must create a server script and specify the part that should spin. You can also speed it up in real time if you need it.
As for the explanation, the CFrame class has a built-in Lerp function. Lerp is a linear function similar to what TweenService uses. 1 argument is the beginning, the second is the end and the third moment in the line graph. That is, 0 is the start and 1 is the end, with this you can move your part smoothly. If you are not familiar with RunService, I encourage you to do so as it is a better solution than loops.
This definitely works well!! Thank you and thank to everyone who dedicated their time to help me in this matter! Good luck to any of y’all upcoming projects and have a wonderful day!
That’s because the NetworkOwnership is always switching to the nearest player, simple set that ownership to always be the server to avoid lag replicating on the spinner.
NetworkOwnership API can only be called on the server (via serverscripts), and you can set ownership by following the example: BasePart:SetNetworkOwnership(player?)
If you leave the parameter blank, or set it to nil, the ownership will direct to the server.