Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Humanoidrootpart not valid member of localplayer? Alternative?

Asked by 2 years ago

So I'm trying to make a game about jumping, and i need the players Y pos so I can put it on a gui, but when i try to pull it from the local player it says " "HumanoidRootPart" is not valid member of MrBucketOfficial" so this means that this doesn't work, but how would I use an alternative? If it helps, I'm using a local script for this and I will put the code below.

local player = game.Players.LocalPlayer
local playerY = player.HumanoidRootPart.Position.Y

playerY.Changed:Connect(function()
    script.Parent.Text = "Height: " .. playerY .. "Studs"
end)

1 answer

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

you have to wait for the player to load like this

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:wait()
--do stuff here
Ad

Answer this question