I started scripting a month ago and i want to know how to get the character postion in my case.
script.Parent.MouseButton1Click:Connect(function() while true do local part = Instance.new("Part", game.Workspace) part.Position = Vector3.new(game.Players.LocalPlayer.Character.UpperTorso.Position) part:Clone() wait(0.0000000001) end end)
I wanted to do a block spam for a lag test but it does not work.
First of all, how is putting a part in someone's torso and duplicating it over and over again related to getting their position?
If you want to know where the character is:
game.Players.PlayerAdded:Connect(function(player) charPos = player.Character.UpperTorso.Position print(charPos) end)
I recommend using the HumanoidRootPart for the position. It works with both R6 and R15.
You can try this:
local CharacterPosition = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position
Ok, I now realize you probably need to wait for the character to load.
local Player = game.Players.LocalPlayer repeat wait() until Player.Character -- Should wait for the "Character" local CharacterPosition = Player.Character:WaitForChild("HumanoidRootPart").Position
function GetCharacterPos(Character) if Character:FindFirstChild("HumanoidRootPart") then local RootPart = Character:FindFirstChild("HumanoidRootPart") return(RootPart.Position) end end -- Anytime you need to get a characters position, just run the fire the function and it will act as a variable giving data. -- Please feed the character(in workspace) -- PLEASE CLICK GET SOURCE SO THE SCRIPT IS PROPERLY FORMATED. print(GetCharacterPos(game.Players.LocalPlayer.Character)) -- This runs the function, then finds the localPlayers postion.