Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you reference a humanoid?

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

2 comments

0

Please specify?

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.

3 answers

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!

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.