How do I rotate a part using a local script? If you know the answer or can lead me in the right direction, that will help me alot.
Thanks in advance.
How do I rotate a part using a local script? If you know the answer or can lead me in the right direction, that will help me alot.
Thanks in advance.
Hello.
You can rotate part in direction you want but in localscript it will be only for client.
That meanns only player will see it
local speed = 5
local Part = workspace.Part
while wait() do
Part.Orientation = Part.Orientation += speed
end
Hope it helps!
You can’t effect a part in the workspace through a local script you will need to use a remote event to do that.
local Part = workspace.Part
local RemoteEvent = Part.RemoteEvent
RemoteEvent:FireServer()
Then in the server script
local Part = workspace.Part
local RemoteEvent = Part.RemoteEvent
RemoteEvent.OnServerEvent:Connect(function())
while true do
wait()
Part.CFrame = Part.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/35)
end
end)
Place the first local script anywhere in the player, (StarterGui)
The RemoteEvent in the part in the workspace
The Second script should go in the ServerScriptStorage.
Any further assistance, just leave a reply.
Sorry I’m a bit confused.
What do I put in the local script and where do I place it?
What do I need to put in the server script and where do I place that?
If it’s on a LocalScript
, be sure it will only fire on the client
.
But, you may use RunService
so it’s fires faster.
For instance:
local part = script.Parent;
local runService = game:GetService("RunService")
local function render_Stepped()
local rotationAdd = 1
part.Orientation = Vector3.new(tonumber(part.Orientation.X), tonumber(part.Orientation.Y) + tonumber(rotationAdd), tonumber(part.Orientation.Z))
end
runService.RenderStepped:Connect(render_Stepped)
-Copy the first bit of code into a local script.
-Then put that local script into the PlayerScripts
-Put the second piece of code into a normal script .
-Then put the script into the ServerScriptStorage
Instead of
Part.Orientation = Part.Orientation += speed
It should be just
Part.Orientation += speed
Or
Part.Orientation = Part.Orientation + speed
(Though it will work, it’s unnecessary to assign the value like you did.)
Why add the while wait() do loop? It should work just fine with the RenderStepped.
Whoops! My mistake, I didn’t write that code on studio so I couldn’t really see that mistake.