Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

btw u forgot the do after game.Players:GetChildren also u should use GetChildren not getplayers

2 answers

✓ Accepted answer

#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.

2 comments

1

oi, gotta geet dat maggie n' chop thru them players findin' the nearest magnitude

0

yes

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

This discussion is preserved as it was. New answers, comments, and votes are closed.