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

How do you reference a humanoid?

Asked by 2 years ago

basically I wanna change an IntValue to a Player's Walkspeed, But I cant seem to reference the player... Can anyone tell me how?

0
Please specify? RAFA1608 543 — 2y
0
Well, I am making Leaderstats, and the leaderstats value is an Int Value. But the Int Value has to be equal to the WalkSpeed of a humanoid, But I dont know how to reference a humanoid. fishboy141516 12 — 2y

3 answers

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
2 years ago

This question was already asked and answered.

https://scriptinghelpers.org/questions/100912/how-to-reference-a-players-humanoid

Ad
Log in to vote
0
Answered by 2 years ago

If it's in a local script, first learn how to get the local player, then the character. Then you can access the humanoid and setup the event to fire whenever the property changes!

Log in to vote
0
Answered by
zane21225 243 Moderation Voter
2 years ago

There are many ways to reference a humanoid. If you're making a leaderboard script, I assume you have some code that triggers when a player joins the server. From that, you can get the player's character and then their humanoid

Here's a quick example:

game:GetService('Players').PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:FindFirstChildOfClass('Humanoid')

    local leaderstats = Instance.new('Folder')
    leaderstats.Name = 'leaderstats'
    leaderstats.Parent = player

    local speed = Instance.new('IntValue')
    speed.Name = 'Speed'
    speed.Parent = leaderstats
    speed.Value = humanoid.WalkSpeed
end)

Answer this question