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

How do you find a certain player's location?

For example when they touch a block, or when they click a GUI something is moved to their location.

1 answer

Given a Player object, we can find the position of a part of them using their Character's Torso/Head's Position.

That would look like:

if player.Character and player.Character:FindFirstChild("Torso") then
	local position = player.Character.Torso.Position;
end

If, for example, we used a Touched event, then we would have a reference to their Character instead of their player.

We would have the choice to either 1) find the torso inside of that Character model or 2) find the Player from the character model and then repeat the above code.

  1. Find torso from hit part
if hit.Parent and hit.Parent:FindFirstChild("Torso") then
	local position = hit.Parent.Torso.Position;
end
  1. Find player from hit
if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
	local player = game.Players:GetPlayerFromCharacter(hit.Parent);
end


In all cases, position would be computed as a Vector3 value.

2 comments

0

And then could I put in a clone script and make it's Vector3 that position (The model will be from the lighting)

0

Of course?

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