I want the code to print the position of the player’s humRP, but it isn’t printing at all. Got the code from another user that said it worked, but it isn’t working for me
--Services
local plr = game:GetService("Players")
--Mainline
plr.PlayerAdded:Connect(function(player) -- when player joins
player.CharacterAdded:Connect(function(char) -- when the player's character is loaded in
local humanoidRootPart = char:WaitForChild("HumanoidRootPart") -- wait for HumRP to load in
while humanoidRootPart do -- while rp loaded in
print(humanoidRootPart.Position) -- print pos of rp
wait(4)
end
end)
end)
why using while humanoidROotPart do when you are already waiting for the HRP to load? try to remove the loop, and if it still doesnt work, try humanoidRootPart.CFrame.Position
--Services
local plr = game:GetService("Players")
--Mainline
plr.PlayerAdded:Connect(function(player) -- when player joins
player.CharacterAdded:Connect(function(char) -- when the player's character is loaded in
local humanoidRootPart = char:WaitForChild("HumanoidRootPart") -- wait for HumRP to load in
print(humanoidRootPart.Position) -- print pos of rp
wait(4)
end)
end)
Changed to humanoidRootPart.CFrame.Position: Not work
--Services
local plr = game:GetService("Players")
--Mainline
plr.PlayerAdded:Connect(function(player) -- when player joins
player.CharacterAdded:Connect(function(char) -- when the player's character is loaded in
local humanoidRootPart = char:WaitForChild("HumanoidRootPart") -- wait for HumRP to load in
print(humanoidRootPart.CFrame.Position) -- print pos of rp
wait(4)
end)
end)
It works, but it needs to be a server side Script, not a LocalScript.
Also, you should remove the loop - or make it so that it terminates when the character resets. It basically recreates another loop each time and you end up with a mem leak.