#player

1 messages · Page 1 of 1 (latest)

quartz frigate
#

how I can detect player's position

jovial walrus
#

keep going explain it @quartz frigate finish the sentense

foggy jungle
#

@quartz frigate

If you're dealing with a Player object, you can do this:

local Players = game:GetService('Players')

-- Let's say you're getting a player from the `PlayerAdded` event
Players.PlayerAdded:Connect(function(player)
                                        -- You'll need to get his character first (the model in the workspace that we control)
                                        
                                        -- Even if this structure below isn't familiar to you, I recommend keep
                                        -- using it until you understand, 'cause this is the best way
                                        -- to get a player's character
                                        
                                        local character = Player.Character or Player.CharacterAdded:Wait()
                                        
                                        -- Now we can get his position from his `HumanoidRootPart`
                                        -- which is an invisible part that every character has (R6 and R15)
                                        
                                        local hrp = character:WaitForChild('HumanoidRootPart')
                                        
                                        -- Parts, Mesh Parts and all instances of `BasePart`
                                        -- category has a `Position` property, which is a Vector3 value
                                        
                                        local position = hrp.Position
                                        
                                        -- Note:
                                        -- This value does not include information about the character's orientation,
                                        -- which means you can't control, for example, where the character will be facing
                                        -- when you set a new position value
end)