Value not being updated on server

Hello, this value is not being updated why, the print prints but the value isn’t updated(btw this isn’t on a gui. This is in the player’s data folder that is not being updated)

	plr.Data.Damage.Value += dps.Value
   print("Updated")

Are there any errors in the output when this is ran?

1 Like

nope the only thing that is in the output is the print “Updated”

Is this the whole script? can you show what DPS is? or give more info about the script?

Dps is another value in player

What type of values are they? are they both numbervalues? To find what type of value they are you can just look at the “classname” property.

Both numbervalues

is this a local script, or a regular ‘script’, also, where is the explorer is the script?

regular script

Ok, when you test it, is this the only script being ran? or like is there a script that changes the value of dps or the damage value first?

dps gets changed first

is DPS changed on a local script? Like the script that changes the value of DPS, is that script a local script or a regular script?

It’s in serverscriptservice in a normal script

Ok, you should add a wait() statement to the script so it gives the server script time to change the value. So it should look like this

wait(2)
plr.Data.Damage.Value += dps.Value
print("Updated")

Also, where is the script with the code:

	plr.Data.Damage.Value += dps.Value
   print("Updated")

Is this code in serverscriptservice?

1 Like

Could you send the whole script with all your variables etc?

Yes the code is in serverscriptservice

local armorFolder = game.ReplicatedStorage.Equipment

game.ReplicatedStorage.Events.EquipArmor.OnServerEvent:Connect(function(plr, armor, condition)
	local dps = plr:WaitForChild("Data").EquippedValue
	
	
	if condition == "Equipped" then
		for index, equippedArmor in pairs(plr.Character:GetChildren()) do
			
			if equippedArmor:IsA("Model")and armor then
				equippedArmor:Destroy()
			end
		end
		for index, chosenArmor in pairs(armorFolder:GetChildren()) do
			if chosenArmor.Name == armor then
				local chosen = chosenArmor:Clone()
				chosen.Parent = plr.Character
				plr.Data.Damage.Value += plr.Data.EquippedValue.Value
				print("Updated")
				for index, armorParts in pairs(chosen:GetChildren()) do
					for index, playerParts in pairs(plr.Character:GetChildren()) do
						if playerParts:IsA("BasePart") then
							if armorParts.Name == playerParts.Name then
								armorParts.PrimaryPart.CFrame = playerParts.CFrame
								local weld = Instance.new("WeldConstraint")
								weld.Part0 = playerParts
								weld.Part1 = armorParts.PrimaryPart
								weld.Parent = armorParts.PrimaryPart
							end
						end
					end
				end
			end
		end
	elseif condition == "Un-equipped" then
		for index, equippedArmor in pairs(plr.Character:GetChildren()) do
			plr.Data.Damage.Value -= dps.Value
			if equippedArmor:IsA("Model") then
				equippedArmor:Destroy()
			end
		end
	end
end)

Ah that is the problem. So the value is updating. It is just that the value will only update on the server side, not for the client side. So you could just put the code into the workspace to fix this.

oh, the value is only updated for client, not server. When i check the serverside the value is not updated but when i check client it is updated