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

How do I get position of my player using charecter?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local position
mouse.Move:connect(function(hit)
	position = mouse.hit.p
end)

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.Z then
		local TeleportLocation = CFrame.new(position)
		local Character = player.Character
		if (Character.Position - mouse.position).Magnitude > 100 then
			Character:SetPrimaryPartCFrame(TeleportLocation)
		else
			print ("Too far away")
		end
	end
end)

what im trying to do is basically get the position of smth using the mouse and teleport my player to the mouse. however an error shows that says 'Position is not a valid member of Workspace.Joseph_Joku please help!

1 answer

The issue is that Character (A model) does not have a Position property. You will want to use their RootPart instead, which can be accessed with Character.PrimaryPart. Alternatively you could do Character.HumanoidRootPart or access their Head and any of their body parts. You can look up the parts by using the explorer

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