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 reach a player position inside a click detector?

Hello, I am a pretty new developer and I have been trying to use a click detector to instance a new part at the player position, but I couldn't find a way to get the position.

here is what I tried: the script is inside the click detector

script.Parent.MouseClick:Connect(function(plr)
	local pos = plr.Character.Humanoid.Position
	local fireBallIn = Instance.new("Part")
	local fireBallOut = Instance.new("Part")
	
end)

but it's not working. it says in the error output that Position is not a valid member of Humanoid. thanks in advance and I am sorry if I wasn't very clear

2 answers

Without looking into it further, I would get the position of the torso and base it off that.

local pos = plr.Character.Torso.Position

1 comment

0

Torso is not a reliable way of finding the player's position, please use HumanoidRootPart.

Humanoid is not a BasePart and won't have a position, it basically holds the players health, walkspeed, jumppower, etc. What you are looking for is HumanoidRootPart which does have a position and is an invisible part that is on top of the Torso part(s). Then you would want to use CFrame.new() with the first input as the position of that HumanoidRootPart block. (Ensure you anchor the parts you make or they will fall down.)

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