Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why are these values not changing?

Asked by 2 years ago

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)
0
is there any errors in output theking66hayday 841 — 2y

1 answer

Log in to vote
2
Answered by 2 years ago

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)
Ad

Answer this question