Problem with an Attribute System (Value doesn't change)

So I’m trying to make an Attribute System, so when you upgrade the damage, you deal more damage.

But the problem is that when I upgrade the Damage, the value in my Attributes Folder (in the player) doesn’t change and is still at 0.


Code which gives me an Attack point when we fire the event :

atkRemote.OnServerEvent:Connect(function(plr)
if not PointsAvailable(plr) then return end

plr.Attributes.Attack.Value += 1
end)

Upgrade Button Code :

local remote = game:GetService("ReplicatedStorage"):WaitForChild("AttributeRemotes"):WaitForChild("AddAttack")

script.Parent.Activated:Connect(function()
	
	if tonumber(script.Parent.Parent.Parent.Total.Value.Text) > 0 then
		script.Parent.Parent.Value.Text += 1
		script.Parent.Parent.Parent.Total.Value.Text -= 1
		
		remote:FireServer()
	end
end) 

Does anyone knows why this is happening?

1 Like

plr.Attributes.Attacks.Value = plr.Attributes.Attacks.Value + 1

Doesn’t work?

1 Like

No it does not work

Also the name of the value isn’t “Attacks” but “Attack”

Where is your PointsAvailable() function?

1 Like

I checked that function, and this one works.

I also realised that when I test and I change the value manually on the client, it doesn’t work.
However if I change the value manually on the server, it works.

I hope this gives you a little clue.

Show code. We can’t help you just by taking your word for it, context is needed.

If you want that code, sure. But this probably won’t help.

local function PointsAvailable(player)
	local PointsUsed = player.Attributes.Health.Value + player.Attributes.Speed.Value + player.Attributes.Attack.Value + player.Attributes.JumpHeight.Value + player.Attributes.MaxStamina.Value
	local PointsAvailable = player.leaderstats.Level.Value - PointsUsed
	return PointsAvailable > 0
end

Are you getting any errors here? If so, then the event that increments Attack.Value isn’t going to fire.

Assuming Text is a UI Property, you are trying to increment a string with a number when it needs to be a string.

script.Parent.Parent.Value.Text = tostring(tonumber(script.Parent.Parent.Value.Text) + 1)
script.Parent.Parent.Parent.Total.Value.Text = tostring(tonumber(script.Parent.Parent.Parent.Total.Value.Text) -1)
1 Like

Nope, not getting any errors in the output.

Also, why does it actually works when I change the value manually in the ‘Server’ mode but doesn’t in the ‘Client’ mode ?

Instance.Attributes.AttributeName

You need to do

Instance:SetAttribute("AttributeName", NewValue)
1 Like

Thanks for the help everyone. But I found out the solution, I deleted the line which checked if we had a point to put, and for some reason, even without that line I couldn’t be able to put one if I had 0 points.