The title might be confusing, but I'm trying to make it so that if the players Y axis is below 466, then a drinking code executes. The problem is that it doesn't detect where the players Y axis is at... It just executes early.
Here's the script.
game.Players.PlayerAdded:connect(function(ply) ply.CharacterAdded:connect(function(char) char:WaitForChild("Torso") local torso = char.Torso torso.Changed:connect(function() if torso.Position.Y <= 466.943 then print("Player is at drinking distance") end end) end) end)
The post has been answered now. Although it is Redbullusa who answered my question, I would like to thank Goulstem too.
The Y
member of a Vector is case senstitive! You need to have Y
rather than y
.
game.Players.PlayerAdded:connect(function(ply) ply.CharacterAdded:connect(function(char) char:WaitForChild("Torso") local torso = char.Torso torso.Changed:connect(function() if torso.Position.Y <= 466.943 then print("Player is at drinking distance") end end) end) end)