Leaderstat Making

Hello

  1. What do you want to achieve? I want to have a saving head growth leaderstat where it puts the size of the head on the leaderstat

  2. What is the issue? I simply cannot do it

  3. What solutions have i tried so far? I have tried Using profileService and watching alvinblox tutorials

local HeadSize = 10000000000000000000
local SpeedOfScaling = 0.0003
local I = 1
local X = 0
local function check(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.HeadScale.Value == 1 then
if X == 0 then
X = 1
I = 1
while I <= HeadSize do
wait(0.01)
hit.Parent.Humanoid.HeadScale.Value = I
I = I+SpeedOfScaling
end
while X == 1 do
X = 0				
wait(0.01)
end		
end
end
end
end

script.Parent.Touched:connect(check)


I am using profileservice, I have the leaderstat, but it just stays at 0

Create a folder inside the player called "leaderstats" and any values inside that folder will show up on the leaderboard. To get the size of the head you could say Character.Head.Size.Magnitude.

Did that in ProfileService

iurhirbibsgiz

My apologies for not reading your post entirely. By a “saving head growth leaderstat” do you mean it saves when you leave and rejoin?

yes, it saves the head size number on the leaderstat as well as the head size itself

Looking into it, I’m not sure I can help you with saving data, I’ve never done anything with that. But I can help you with just making the leaderstat value change.

Also Humanoid.HeadScale.Value only works for R15, if you want a global rigtype option you can say Character.Head.Size.Magnitude.

Use a changed signal event to get the size of the head and then change the value.

Character.Head:GetPropertyChangedSignal"Size":Connect(function()
	HeadSizeValue.Value = math.round(Character.Head.Size.Magnitude)
end)

and also just make sure to set the value before adding this because the value will only change when the characters head size changes, meaning it will stay at zero until the players head size has changed.

thats ok

Didnt know that! Nice
Still using r15 tho

Do I put this in the same script? or is it better in the same one
stupid question nvm

Trying this out,

Put it in the PlayerAdded event. If you only use R15 in your game then it’s fine to use Humanoid.HeadScale.Value, because there are several values inside the humanoid’s of R15 RigType models representing body scale which are useful if you ever wanted to make something like a body scaler like in Robloxian Highschool. I hope one day Roblox will add body scale value’s for R6 RigTypes but I doubt that’ll ever happen as Roblox is aiming to make Rthro types more popular.

1 Like

you should format your code

You will first need to get the player using Players:GetPlayerFromCharacter(hit.Parent). If it exists, you should go into the leaderstats and set it to the value of the HeadScale. Simple.

I can also help you with saving data, if you need that as well.

you would need to use serialization

get the headsize in a variable / intValue

and do headsize = value

Right, it is kinda sloppy

Ok

I have ProfileService, its ok

What is that

Qazqazqazqazqazqaz

Ok, I have unknown globals

Character, HeadSizeValue and, Character

There is no PlayerAddedEvent in this script

I am clueless here

You want the leaderstats to affect all players who join right? Use a PlayerAdded event, I have no idea what the “ProfileService” is, I’ve honestly never heard of it and don’t know how you could be using it to add leaderstats. The “HeadSizeValue” is the integer value (or float, whichever you choose) inside the leaderstats folder representing what size the characters current head size is.

This is how I would organise it:

local Players = game:GetService"Players"

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local LeaderStats = Instance.new("Folder", Player)
		LeaderStats.Name = "leaderstats"
		local HeadSize = Instance.new("IntValue", LeaderStats)
		HeadSize.Name = "Head Size"
		HeadSize.Value = math.round(Character.Head.Size.Magnitude)
		
		Character.Head:GetPropertyChangedSignal"Size":Connect(function()
			HeadSize.Value = math.round(Character.Head.Size.Magnitude)
		end)
	end)
end)

edit:
ACTUALLY now that I’ve come to look further into this, I’ve realised .Changed and :GetPropertyChangedSignal"" don’t work for detecting a change in head size for whatever reason, the only changed signal event I could receive is “parent”. However I’ve come to know that both methods will work for value instance. So if you structure the event like this it will work.

local Players = game:GetService"Players"

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local LeaderStats = Instance.new("Folder", Player)
		LeaderStats.Name = "leaderstats"
		local HeadSize = Instance.new("NumberValue", LeaderStats)
		HeadSize.Value = Character.Head.Size.Magnitude
		
		local Value = Instance.new("NumberValue")
		
		Value:GetPropertyChangedSignal"Value":Connect(function(Property)
			HeadSize.Value = Character.Head.Size.Magnitude
		end)
		
		spawn(function()
			while true do task.wait()
				Value.Value = Character.Head.Size.Magnitude
			end
		end)
	end)
end)

Its just another Datastore that prevents dataloss

Thanks for the help