Problem with "Value" Server Dosen't remember my "-Value"

  1. What do you want to achieve? So Hare my problem, if i click Then My Animation Work (With +Value) But if player have “10 Value” and he “-All Value” then My animation not work, But if i back my “10 Value” My animation work again to more value

  2. What is the issue? Include screenshots / videos if possible!

Hare Problem

local players = game:GetService("Players")
local playerLocal = players.LocalPlayer
local leaderstats = playerLocal:WaitForChild("leaderstats") 
local Value1 = leaderstats:WaitForChild("Coin") 

local playerGui = playerLocal:WaitForChild("PlayerGui")
local screenGui = playerGui:WaitForChild("Text_Value")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ValuePopUpTemplate = ReplicatedStorage:WaitForChild("Gui_Coin")

local odlCoinValue = Value1.Value

Value1.Changed:Connect(function()
	local CoinPopUp = ValuePopUpTemplate:Clone()
	CoinPopUp.Parent = screenGui
	
	local randomNum1 = math.random(3,8)/10
	local randomNum2 = math.random(1,7)/10
	
	local newCoinValue = Value1.Value
	local value = newCoinValue - odlCoinValue
	if value > 0 then
		CoinPopUp.amount.Text = "+"..value
		odlCoinValue = Value1.Value
                  Animation()
	end
end)

am gas its problem with this

local odlCoinValue = Value1.Value

if yes i dont no how to fix, if no, well. I need help

  1. What solutions have you tried so far?
    I try see in youtobe this problem to, but i see nothing abount this

Why not just use a remote event and make a parameter the value, and make the client receive it? Also not sure but by the looks of it, it would also be safer to use the remote event.

I will know for the future, but you now how to fix this problem with “-Value”?

I’m assuming you are referring to the wood being “-1” for that just add a check to see if the player’s active Wood.Value or whatever the name is isn’t going below 0 and if it does just return so it doesn’t get updated client side. If you could show that script I could assist you further since the one you supplied only works for coins.

The script is approximately the same as in Coins. There is the same problem.

Could you show me the server script that changes the value?

script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	plr.leaderstats.Coin.Value -=  1
end)

Try this and see if it works

script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	local coinInstance = plr.leaderstats.Coin
	if (coinInstance.Value - 1) >= 0 then
		print("Calculation says we are clear to go")
		coinInstance.Value -=1
	else
		print("Cannot since the value will be negative")
	end
end)

Same problem

–Hare whare my all scripts


– its my animation Gui in player Gui

Well hare its problem

local odlCoinValue = Value1.Value

we can just doing

local value_New = newCoinValue - odlCoinValue
local Value_Old = odlCoinValue - newCoinValue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.