Soo, I am making a script that if the player’s torso is between selected X and Z then it’ll play the sound.
But for some reason, if Vector3’s Z is inserted then it’ll return nil… what??
Would be kind for some help!


Soo, I am making a script that if the player’s torso is between selected X and Z then it’ll play the sound.
But for some reason, if Vector3’s Z is inserted then it’ll return nil… what??
Would be kind for some help!
Hey, would you mind sharing the line of code that does this so I can debug it? Plus the screenshot you attached doesn’t load for me.
The >
and <
signs are backwards. Currently you are checking if the player’s Z is more than 21.5 and less than -77.5, which is, simply put, impossible.
if Torso.Position.X > -6.5 and Torso.Position.X < 92.5 and Torso.Position.Y < 166 and Torso.Position.Y > 126 and Torso.Position.Z > 21.5 and Torso.Position.Z < -77.5 then
return "Lobby"
end
@hannes213 told you that both <
and >
are simply wrong, you need to invert them.
-- Current:
Torso.Position.Z > 21.5 and Torso.Position.Z < -77.5
-- New:
Torso.Position.Z > -77.5 and Torso.Position.Z < 21.5
still returns nil even if i switch to the new line of the code
Hey, try the code bellow. I switched the .Y value as well.
if Torso.Position.X > -6.5 and Torso.Position.X < 92.5 and
Torso.Position.Y > 126 and Torso.Position.Y < 166 and
Torso.Position.Z > -77.5 and Torso.Position.Z < 21.5 then
return "Lobby"
end
Could you try this:
local XPosition = (Torso.Position.X >= -6.5 and Torso.Position.X <= 92.5)
local YPosition = (Torso.Position.Y >= 126 and Torso.Position.Y <= 166)
local ZPosition = (Torso.Position.Z >= -77.5 and Torso.Position.Z <= 21.5)
if XPosition and YPosition and ZPosition then
return "Lobby"
else
return tostring(Torso.Position)
end
-- Or this (same result)
if (Torso.Position.X >= -6.5 and Torso.Position.X <= 92.5) and (Torso.Position.Y >= 126 and Torso.Position.Y <= 166) and (Torso.Position.Z >= -77.5 and Torso.Position.Z <= 21.5) then
return "Lobby"
end
You could try using Torso.CFrame.Position.Z to see if it returns a Z value
one of my friends already helped me with this
i thank my friend for helping me out
and to anyone else that tried helping.
i am bad at scripting at some point :g