The GemVal(IntValue) is a child of a Textlabel, I want the GemVal to change whenever the numberValue of a certain leaderstat changes (the rebirth value), which is working just fine, what I don't know how to do is saving the data for the GemVal whenever the player leaves.
Both are in StarterGui
while true do wait(0.01) script.Parent.Text = game.StarterGui.ShopGui.Frame.Gems.GemAmount.GemVal.Value end
Causes leaderstat change
local player = game.Players.LocalPlayer local Speed = player:WaitForChild("leaderstats").Speed local Gem = game.StarterGui.ShopGui.Frame.Gems.GemAmount.GemVal local frame = script.Parent.Parent script.Parent.MouseButton1Click:Connect(function() if Speed.Value >= 5000 then print("rebirth:", player) workspace.RebirthEvent.Rebirth:FireServer() --rebirth (in leaderstat) change Gem.Value = Gem.Value + 1 wait(.5) frame:TweenPosition(UDim2.new(0.38, 0,0.226, 1000)) else script.Parent.Parent.Required.TextColor3 = Color3.new(255, 0, 0) wait(.75) script.Parent.Parent.Required.TextColor3 = Color3.new(255, 255, 255) end end)
OnServerEvent
script.Rebirth.OnServerEvent:Connect(function(player) player.leaderstats.Rebirth.Value = player.leaderstats.Rebirth.Value +1 player.leaderstats.Speed.Value = 0 end)
I have no idea on how to save the GemVal, because any attempt I have done so far messes with the DataStore that I originally had for player leaderstats and causes an error.