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.

8 comments

0

Just so you know you used Color3.new wrong, it takes arguments between 0 and 1. However since it gets rounded down to 1

0

oh, It's been working for me so I didn't suspect anything, also can't I use Color3.fromRGB

0

yes

0

and please post your code that has the OnServerEvent stuff

0

alrighty

0

I recommend you save data in a table and load it in a table by using GetAsync and SetAsync make sure to insert your value into the table

0

I have a table already and I tried to add it into that and thats how I got the leaderstats error

0

Did you check if another script is changing it?