Hello, since a lot of hours ago i want to do something but it never leads to something i’m a begginer in scripting and this hard for if i can have help thanks. error : “attempt to call a nil value” you will undertand what i want to do by read the script difficult to explain.
local plane = script.Parent.Plane.Value.Parent
local sensor = plane.MainParts.Engine:WaitForChild("BodyGyro").CFrame
local baseSpeed = plane.MainParts.PilotSeat:WaitForChild("BaseSpeed")
local Running = true
local bg = plane.MainParts.Engine:WaitForChild("BodyGyro")
local StallSpeed = require(plane.Settings.Config).StallSpeed
local PitchSpeed = require(plane.Settings.Config).PitchSpeed
local function getz()
local angles, numberIGuess = CFrame:ToAxisAngle() --error here
local a = CFrame.ToAxisAngle(sensor)
return a[3]
end
local function ok()
while Running == true do
if baseSpeed.Value > (StallSpeed - 50) and baseSpeed.Value > 200 then
local x = getz()
print(x)
if CFrame.ToAxisAngle(sensor) >= -15 and CFrame.ToAxisAngle(sensor) <= 15 then --error here i wanted to do the same but no
plane.Events.Takeoff:FireServer("PitchRing", "PitchRing", "PitchRing")
end
end
wait(0.1)
end
end
ok()
i just want to get the Z value of rotation of a BodyGyro
You did not specify which CFrame if im not wrong
So I guess you shuold do something like Part.CFrame:ToAxisAngle(sensor)
As well as CFrame.ToAxisAngle(sensor)
is not how you call a function - so replace it with CFrame:ToAxisAngle(sensor)
local function getz()
local angles = sensor:ToAxisAngle(sensor)
local angles, numberIGuess = CFrame:ToAxisAngle(sensor)
print(numberIGuess)
return numberIGuess[3]
end
need to be like this ?
I guess the thing you really want to have is:
local function getz(bg)
local angles, numberIGuess = bg.CFrame:ToAxisAngle()
local a = bg.CFrame:ToAxisAngle()
return a[3]
end
And then call it by getz(bg)
sensore is a var in the script then don’t need the bg for the function
with your function i got this error :
invalid argument #2 (string expected, got number)
for the return
Ok, so I did this rq in studio. Lmk if it works for you
local function getz(bg)
local angles, numberIGuess = bg.CFrame:ToAxisAngle()
local a = bg.CFrame:ToAxisAngle()
local stringa = a.Z
return stringa
end
print(getz(bg))
i tested in game but it dont capture the Z it’s weird
do you have discord i will screenshare to you ?
I abandonned this solution and just add a invisible part for get it.