You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want my “Egg” Int Value to save. All my other 3 Number Values are saving perfectly fine. But my last one, Egg doesnt work for some reason -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The best I can do is explain what Egg does. Basicly when you open an egg your egg value will go up by +1 or +3. This gets added from other scripts.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- function getMultiplier(Player, multiplier1)
-- Multiplier1 or Multiplier2
local Multi = 0
for i,v in pairs(Player.Pets:GetChildren()) do
if v.Equipped.Value == true then
Multi = Multi + v[multiplier1].Value
end
end
return Multi
end
local Event = Instance.new("RemoteEvent")
Event.Name = "ClickEvent"
Event.Parent = game:GetService("ReplicatedStorage")
local PlayerStatsDS = game:GetService("DataStoreService"):GetDataStore("Test621")
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
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)
game:GetService("ReplicatedStorage"):WaitForChild("ClickEvent").OnServerEvent:Connect(function(plr)
plr:WaitForChild("leaderstats"):FindFirstChild("Clicks").Value = plr:WaitForChild("leaderstats"):FindFirstChild("Clicks").Value + plr:WaitForChild("leaderstats"):FindFirstChild("Rebirths").Value * getMultiplier(plr, "Multiplier1") * 2
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.