Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why are these values not changing?

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)

1 comment

0

is there any errors in output

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.