Why is this not detecting that the player is not in range?
This is supposed to print something when the player is hovering over a certain item and within 10 studs and it definitely does print but it does not matter how far the player is for some reason.
01 | local m = require(workspace:WaitForChild( "Modules" ):WaitForChild( "MainModule" )) |
02 | local RunService = game:GetService( "RunService" ) |
03 | local player = game:GetService( "Players" ).LocalPlayer |
04 | local char = workspace:WaitForChild(player.Name) |
05 | local Mouse = player:GetMouse() |
07 | RunService.RenderStepped:Connect( function () |
08 | local target = Mouse.Target |
09 | if target:FindFirstChild( "CanHarvest" ) then |
10 | if target:FindFirstChild( "CanHarvest" ) then |
11 | if char.UpperTorso.Position.X - target.Position.X > - 10 or char.UpperTorso.Position.X - target.Position.X < 10 then |
12 | if char.UpperTorso.Position.Z - target.Position.Z > - 10 or char.UpperTorso.Position.Z - target.Position.Z < 10 then |
13 | print ( "ITS WORKING! (Maybe)" ) |