I’m trying to create a lava spinner that rotates on Client to prevent lag.
So, I tried inserting a local script containing a remote event and firing it on the server to rotate the spinner, however it’s not working.
Could somebody please help me? Thanks!
If you fire the server and perform the spinning in a server script then the spinning will be handled by the server.
I did that but nothing happened.
Could you provide the script? Also, did you make sure the event was received (via print or warn or something that shows it was received)
Server script:
local Part = workspace.Spinner_1
local RemoteEvent = game.ReplicatedStorage.RotatePart
RemoteEvent.OnServerEvent:Connect(function()
while true do
wait()
Part.CFrame = Part.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/35)
end
end)
Local Script:
local rotatePart = game.ReplicatedStorage.RotatePart
rotatePart:FireServer()
This code runs on the server, I think you have it mixed up if you want it to run on clients. Also, in what way is it not working? Is it not rotating at all, or lagging?
Its not rotating at all. It’s just staying still.
Something else you could consider is using physics to rotate the object instead with a HingeConstraint. If I were you, I’d look into it:
Sorry, I can’t. My spinner was just not meant to be functioned using a hinge constraint.
Why not? It would make the game LOADS more efficient since it doesn’t have to update the rotation of a part over and over. What prevents you from doing so?
So I always believed using a hinge constraint would move require moving the part with the player’s body to rotate it. But, what if it was a kill brick?
I believe something like this should work:
EDIT: Place this script in StarterPlayerScripts
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local function rotateSpinners()
for i, v in pairs(workspace.Spinners:GetChildren()) do --Spinner Folder
local tween = tweenService:Create(v, tweenInfo, {CFrame = v.CFrame * CFrame.Angles(0, math.rad(180), 0)})
tween:Play()
end
wait(1)
end
while true do
rotateSpinners()
end
Didnt work, nothing happened and once again no errors.
Where did you put the script? (30000)
starter player scripts like u said
A HingeConstraint can be configured to act as a motor, spinning on its own.
I REALLY wouldn’t recommend rotating with scripts, it’s extremely inefficient.
Oh it was rotating just the wrong way. Thank you so very much!
The only other possiblity I can think of is you’re not pathing to your spinners correctly.
I used:
- Workspace > Spinners (Folder) > Parts
The loop gets the children of that folder (assuming they’re all parts) and tweens the rotation.
What nvm, I don’t know whats happening its not rotating on studio but its rotating on game???
Allow me to introduce myself. My name is Mr. Idiot and I have the brain of a rock. My script was right its just that roblox studio does not run in Client when pressing the run button. So, it works thanks though everybody.