Get player position

local playerpos = game.Players.(insert username).Character.Torso.CFrame
local op = Instance.new(“Part”,Workspace)
op.Position = Vector3.new(playerpos)

Im trying to make a ball that spawns at the player, but i dont really know how. I tried getting the torso’s CFrame value (playerpos is the CFrame value) and put it into a Vector3(). Any help? Thanks.

1 Like

Try replacing Character.Torso.CFrame with Character.HumanoidRootPart.Position

3 Likes

The part spawns in the middle of the map somehow.

2 Likes

local player = game.Players:WaitForChild(player name)
local playerpos = player:WaitForChild(“HumanoidRootPart”).Position

try this

1 Like

I don’t really know when this code is supposed to run so I just put it in a Players.PlayerAdded event

game.Players.PlayerAdded:Connect(function(player)
	if player then
		local Character = player.Character or player.CharacterAdded:Wait()
		if Character then
			local playerpos = Character and Character:FindFirstChild("Torso") and player.Character.Torso.CFrame.Position
			if playerpos then
				local op = Instance.new("Part", workspace)
				op.Position = playerpos
			end
		end	
	end
end)
2 Likes

I restarted roblox studio and it worked. Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.