I'm trying to update values but the values don't change when the event is fired
In a server script
rep = game:GetService("ReplicatedStorage") event = rep.Events.PlayerRebirth function onRebirth(player) local rebirths = player.leaderstats.Rebirths.Value local speed = player.leaderstats.Speed.Value local mult = player.Multiplication.Value print(player) print(speed) print(rebirths) speed = 3 rebirths = rebirths + 1 mult = 5 end event.OnServerEvent:Connect(onRebirth)
You set them as a variable, and when it becomes a variable, only the numerical value of the IntValue will only change, not the IntValue itself. So instead, use IntValue.Value = int
.
rep = game:GetService("ReplicatedStorage") event = rep.Events.PlayerRebirth function onRebirth(player) local rebirths = player.leaderstats.Rebirths local speed = player.leaderstats.Speed local mult = player.Multiplication print(player) print(speed) print(rebirths) speed.Value = 3 rebirths.Value += 1 mult.Value = 5 end event.OnServerEvent:Connect(onRebirth)