My Solution would also need you to create a new value because you need to keep track of how many flex points was made in the past to accurately gift new flex points
I don’t believe there is a way to do it without making a new value but… I can see why you wouldn’t want to
setting up the PlayerAdded script that loads in the data for players you’d have to interact/update it
1 Like
Adding new values isn’t going to cause a drastic performance decrease, it may be the only solution possible, unless someone else has another solution
1 Like
Just out of curiosity is there a reason as to why you’re using a touched interest on a part?
If not, then you could use something similar to; I left out the decrementing of time because one of your comments made it seem like that wasn’t necessary.
local Players = game:GetService("Players");
local function PlayerAdded(Player)
local Stats = Player:WaitForChild("leaderstats", 20);
local PlayerTime = Stats and Stats:WaitForChild("TIME", 20);
local FlexPoints = Stats and Stats:WaitForChild("Flex_Points", 20);
if PlayerTime and FlexPoints then -- Not it won't make it passed here if those values are not created
PlayerTime:GetPropertyChangedSignal("Value"):Connect(function()
if PlayerTime.Value % 1000 == 0 then
FlexPoints.Value += 1;
end
end)
end
end
for _, Player in pairs(Players:GetPlayers()) do
PlayerAdded(Player); -- The reason this is here is due to a studio issue
-- if you're not testing in studio then this isn't needed.
end
Players.PlayerAdded:Connect(PlayerAdded);
However, if you’re wanting to keep it as a part touch, then pay no mind to my response. Also wouldn’t recommend saving, with a datastore, each time a value updates (if you are) cus that will run into data limits.