So when I'm not even close it still prints this idk why
01 | local mic = workspace.AnnouncerTable.MIC.Main |
02 | local range = 5 |
03 |
04 | game.Players.PlayerAdded:Connect( function (p) |
05 | p.CharacterAdded:Connect( function (char) |
06 | if char ~ = nil then |
07 | local torso = char.Torso |
08 | if (mic.Position-torso.Position).magnitude > = range then |
09 | print (p.Name.. " Is close" ) |
10 | end |
11 | end |
12 | end ) |
13 | end ) |
Looking at your code, it only runs once when the player joins and when the player resets. If you take a look at line 8, you would see
1 | if (mic.Position-torso.Position).magnitude > = range then |
This basically says "if the mic part and the torso distance is bigger than or equal to the range variable then print. You would want to change it so it is if the distance is less than or equal. So just change the >= to <= and you should be set
I have tested this in-game and it will work, I noticed that you aren't looping the magnitude checking so I have put one in for you. As I have mentioned before, you needed to change >=
to <=
01 | local mic = workspace.AnnouncerTable.MIC.Main |
02 | local range = 5 |
03 |
04 | game.Players.PlayerAdded:Connect( function (p) |
05 | p.CharacterAdded:Connect( function (char) |
06 | while wait() do |
07 | local torso = char.Torso |
08 | if (mic.Position-torso.Position).magnitude < = range then |
09 | print (p.Name.. " Is close" ) |
10 | end |
11 | end |
12 | end ) |
13 | end ) |