Look at this:
There is no script inside your Rebirths IntValue. You are never telling the game to detect a Change event and then clamp the value.
Look at this:
There is no script inside your Rebirths IntValue. You are never telling the game to detect a Change event and then clamp the value.
I redid the âIntConstrainedValueâ test and it again limited the rebirth value to just 10
What should I do for him to detect these events?
Show me the code where you clone the stuff in the Stats
folder and move it to the leaderstats
folder.
Iâm guessing thatâs your Leaderstats
script.
I looked for a script talking about a clone of the statistics folder, but I didnât find it (the game is a little disorganized) but for now I will send this script from leaderstats when I am looking for
Leaderstats(script)
local PlayerStatsDS = game:GetService("DataStoreService"):GetDataStore("Player_StatsOL2")
game.Players.PlayerAdded:Connect(function(NP)
local Key = "PDS-".. NP.UserId
local GetSave = PlayerStatsDS:GetAsync(Key)
local PSF = Instance.new("Folder", NP)
PSF.Name = "leaderstats"
local StatsFolder = script.Stats
for _, S in pairs(StatsFolder:GetChildren()) do
local NS = Instance.new(S.ClassName, PSF)
NS.Name = S.Name
NS.Value = S.Value
end
local timeplayed = PSF:WaitForChild("Time Played")
spawn(function()
while true do
wait(1)
timeplayed.Value = timeplayed.Value + 1
end
end)
if GetSave then
for n, Stat in pairs(PSF:GetChildren()) do
Stat.Value = GetSave[n]
end
else
local STS = {}
for _, Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
end
PlayerStatsDS:SetAsync(Key, STS)
end
end)
game.Players.PlayerRemoving:connect(function(OP)
local Key = "PDS-".. OP.UserId
local StatsFolder = OP.leaderstats
local STS = {}
for _, Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
end
PlayerStatsDS:SetAsync(Key, STS)
end)
This comes from using code that you donât really understand. I suggest brushing up more on how scripting works in the Roblox Dev Tutorials to better help you.
This chunk of the Leaderstats
script is the part that takes what you have in the Stats folder and then places new values in the leaderstats
folder, of which the variable is called PSF.
local StatsFolder = script.Stats
for _, S in pairs(StatsFolder:GetChildren()) do
local NS = Instance.new(S.ClassName, PSF)
NS.Name = S.Name
NS.Value = S.Value
end
The problem is, it creates brand new values. The script you made for the Rebirths value only works for that specific Rebirth Value.
This is because the code youâre using takes the data from the Rebirth Value and just makes a whole new rebirth value instead, which doesnât have that code in it.
A better system should be made, instead of using this one.
However, because you are still learning code, and you should continue to do so, you donât yet have the ability to fix the code and make it properly duplicate the values with all their data copied over as well.
Try this.
Replace:
for _, S in pairs(StatsFolder:GetChildren()) do
local NS = Instance.new(S.ClassName, PSF)
NS.Name = S.Name
NS.Value = S.Value
end
with
for _, S in pairs(StatsFolder:GetChildren()) do
local NS = S:Clone()
NS.Parent = PSF
end
It may or may not break the rest of the code. Likely it wonât.
incredible, now the playerâs script is appearing and it didnât break the game
I will try to use an IntConstrainedValue
Does it show the before/after message?
I saw in the output, but there was nothing
I used an IntConstrainedValue and it worked, thank you so much man for helping me without judging myself for not knowing much
it was â Deprecatedâ
place a server script under the int valu and add this code in it
script.Parent.Changed:Connect(function(x)
script.Parent.Value=math.clamp(x,0,1000000000)
end)