I’m trying out the new DragDetectors but have run into a problem reading the DragFrame Orientation X value.
I want to use a lever (NOT a slider Position
like all the tutorial places or documentation suggest) but because of my very basic knowledge of CFrames I can’t get the Orientation.X value to print. I know how to convert radians to degrees so that’s not the issue.
When I playtest and look at the DragFrame.Orientation.X value it changes with the lever from 0 to 90 as I move it. Simple, right?
I want to use just the X value in the formula to change the chandelier lights Brightness in the folder. Anything I read seems to indicate I have to get the CFrame of the Lever Part and use that, but since its CFrame is rotated in the workspace the X,Y,Z values don’t just change from 0 to 90 as I’d like.
lights = script.Parent.Lights
drag = script.Parent.Lever.DragDetector
--[[ --issues here I can fix, but I need to use the degrees of the X angle.
function dimmer(angle)
for _, light in next, lights:GetChildren() do
light.Transparency = angle/180 + .5
if light.Name == "Bulb" then
light.Light.Brightness = angle/180
end
end
end]]
function leverChanged()
local angle = drag.DragFrame.Rotation
--dimmer(angle)
print("lever angle = ", angle)
end
drag:GetPropertyChangedSignal("DragFrame"):Connect(leverChanged)
The prints I get in the output window look like CFrame values to me:
01:06:37.826 lever angle = 0, 0, 0, 1, -3.45619228e-05, 5.9604627e-08, 1.5050171e-05, 0.433901489, -0.900960326, 3.1113057e-05, 0.900960326, 0.433901489 - Server - DimmerScript:18
I know it’s probably such a simple thing to fix, but man I always have problems converting CFrame values to something I can use in my scripts…
Thanks!