So I have a part on a plane that moves and the attitude gauge. How can i detect every time the parts x orientation changed by lets say 0.1 it rotates the gauge for the same amount(also if you know how to do it no need to write the gauge rotation just a way I can detect if the orientation changed)
You should probably just update the gauge every frame according to the plane’s rotation instead with BindToRenderStep:
game:GetService'RunService':BindToRenderStep('updateGauge', 201, function() --reposition gauge according to plane's orientation end)
This ensures the gauge remains updated at all visibilities and has a very accurate reading. When the gauge is no longer needed, you can unbind the render with UnbindFromRenderStep.
its not a gui gauge its an actual part
and also I am looking at the plane rotation
You can change and access properties of parts in a RenderStep as well. I’m assuming only the player who drives the plane needs to see the gauge. If it needs to update for the entire server, simply use Heartbeat on the server or update it for each individual client.
no thats not what im going for I just need to detect everytime the main part in the plane has rotated for 0.1
If you want to detect if the orientation is changed, what I would do is adding a renderstep function. First I will be adding an orientation of a part, then in the renderstepped service, there’s a new orientation. Why do we need that? We need those to detect if the orientation has changed. If it’s changed, you can add the code. After the comment, The orientation is set to the new orientation. Lastly, the orientation is updated for the renderstep to run it as a loop again.
local RunService = game:GetService("RunService") local orientation = -- Full name of part (Example: script.Parent.Orientation) RunService.RenderStepped:Connect(function(step) local newOrientation = script.Parent.Orientation if orientation ~= newOrientation then -- code end orientation = newOrientation end)
But if you want to detect if it’s rotating than 0.1 or more (What I’m assuming by your last message), Just detect if it’s the newOrientation.X is bigger than the findOrientation.
local RunService = game:GetService("RunService") local orientation = script.Parent.Orientation -- Full name of part (Example: script.Parent.Orientation) RunService.Stepped:Connect(function(step) local newOrientation = script.Parent.Orientation if orientation.X ~= newOrientation.X then local findOrientation = orientation.X if newOrientation.X > findOrientation + .1 then print("going left") else print("going right") end end orientation = newOrientation end)