Creating instance in a player character won't work

  1. What do you want to achieve? Keep it simple and clear!
    I want to create a value in player’s character when they joined

  2. What is the issue? Include screenshots / videos if possible!
    it won’t create

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Searching

game.Players.PlayerAdded:Connect(function(player)
	local HeartRate = Instance.new("IntValue")
	HeartRate.Parent = player.Character
	HeartRate.Name = "HeartRate"
	HeartRate.Value = 60
end)

The script is a server script in Server script service

The character is nil when the player joins because it needs to load use .CharacterAdded to ensure the character has loaded, simply just make a characteradded connection to a function and then paste that group of code inside of the characteradded

3 Likes