here's the LOCAL script:
--in a local script, instantiate all unchanging variables outside of functions local localPlayer = game.Players.LocalPlayer local PlayerName = localPlayer.Name local WorkspaceCharacter = game.Workspace:WaitForChild(PlayerName) local charHead = WorkspaceCharacter:WaitForChild("Head") local charPos = charHead.Position -- why set the left foot of the character or the player name to a variable if you never use it? script.Parent.MouseButton1Click:Connect(function() local NewPart = Instance.new("Part")--second arg is deprecated NewPart.Position = Vector3.new(charPos)--don't forget to close your functions NewPart.Parent = game.Workspace --set the parent after setting all of the other properties of the new part end)
Changing the Position will not clip the part into the character's head. You will need to change the part's CFrame for this. You should also make sure that the part is anchored. Furthermore, you are only getting the player's head position once, when the script is first ran. To get the head position every time the mouse button is clicked, you need to define that variable inside the function every time it is ran.
For the part to go inside the head:
--in a local script, instantiate all unchanging variables outside of functions local localPlayer = game.Players.LocalPlayer local PlayerName = localPlayer.Name local WorkspaceCharacter = game.Workspace:WaitForChild(PlayerName) local charHead = WorkspaceCharacter:WaitForChild("Head") -- why set the left foot of the character or the player name to a variable if you never use it? script.Parent.MouseButton1Click:Connect(function() local charPos = charHead.CFrame local NewPart = Instance.new("Part") NewPart.Anchored = true NewPart.CFrame = charPos --I am turning CanCollide off so the player doesn't get flung or something similar NewPart.CanCollide = false NewPart.Parent = game.Workspace end)
For the part to go on top of the head:
--in a local script, instantiate all unchanging variables outside of functions local localPlayer = game.Players.LocalPlayer local PlayerName = localPlayer.Name local WorkspaceCharacter = game.Workspace:WaitForChild(PlayerName) local charHead = WorkspaceCharacter:WaitForChild("Head") -- why set the left foot of the character or the player name to a variable if you never use it? script.Parent.MouseButton1Click:Connect(function() local charPos = charHead.CFrame * CFrame.new(0, charHead.Size.Y/2, 0) local NewPart = Instance.new("Part") NewPart.Anchored = true NewPart.CFrame = charPos --I am turning CanCollide off so the player doesn't get flung or something similar NewPart.CanCollide = false NewPart.Parent = game.Workspace end)