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 4 years ago

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

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

2 answers

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

Very Good (and unclear) Instructions

  1. Do a dance with variables like this example:
maggie = (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:
if maggie <= 2.53 then -- just make sure you can get 2.53 and under using "<="
print(i.." is near an object within its radius of 2.53!")
end
  1. Ask the Lua nerd next to you. He may tell you to combine that with your code, like this:
maggie = (xyz_A-xyz_B).magnitude

for _, i in pairs(game.Players:GetPlayers())
    if maggie <= 2.53 then
        print(i.." is near an object within its radius of 2.53!")
    end
end

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 — 4y
0
yes speedyfox66 237 — 4y
Ad
Log in to vote
1
Answered by
TNTIsLyfe 152
4 years ago
Edited 4 years ago

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

for _, i in pairs(game.Players:GetChildren())
while true do
if i:PlayerDistanceFromCharacter(Vector3.new(number,number,number)) < 2.53 then   
        print("Player is near an object within its radius of 2.53") 



    end
end
end

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

Answer this question