Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I make players know if they are near an object within its radius?

Asked by 5 years ago

Where should I start? I don't know much about magnitude but this is my code so far.

1for _, i in pairs(game.Players:GetPlayers())
2    if i == workspace.Part.Magnitude then
3        print("Player is near an object within its radius of 2.53") --Something like this.
4    end
5end
0
btw u forgot the do after game.Players:GetChildren also u should use GetChildren not getplayers TNTIsLyfe 152 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Very Good (and unclear) Instructions

  1. Do a dance with variables like this example:
1maggie = (xyz_A-xyz_B).magnitude

-- xyz1 and xyz2 could be "workspace.PartThingy.Position" (as an example)

  1. Make a funny face at math and use this as an example:
1if maggie <= 2.53 then -- just make sure you can get 2.53 and under using "<="
2print(i.." is near an object within its radius of 2.53!")
3end
  1. Ask the Lua nerd next to you. He may tell you to combine that with your code, like this:
1maggie = (xyz_A-xyz_B).magnitude
2 
3for _, i in pairs(game.Players:GetPlayers())
4    if maggie <= 2.53 then
5        print(i.." is near an object within its radius of 2.53!")
6    end
7end

and then that same Lua nerd will let you do the rest.

1
oi, gotta geet dat maggie n' chop thru them players findin' the nearest magnitude royaltoe 5144 — 5y
0
yes speedyfox66 237 — 5y
Ad
Log in to vote
1
Answered by
TNTIsLyfe 152
5 years ago
Edited 5 years ago

U should try use PlayerDistanceFromCharacter and set the vector point of the object something like this maybe

01for _, i in pairs(game.Players:GetChildren())
02while true do
03if i:PlayerDistanceFromCharacter(Vector3.new(number,number,number)) < 2.53 then  
04        print("Player is near an object within its radius of 2.53")
05 
06 
07 
08    end
09end
10end

not sure if this will work im just guessing might work i guess

Answer this question