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

Changing an int value in Replicated Storage not working (?)

Asked by
figo30 9
6 years ago
local wave = game.ReplicatedStorage.Wave.Value
wave = wave + 1

For some reason this isn't working, it stays at 0 when the game is launched.

Any help is much appreciated.

1 answer

Log in to vote
0
Answered by 6 years ago

First you have to be sure you make it a serverscript

But the actual problem is the game.ReplicatedStorage.Wave.Value will result in something like this for the script

local wave = game.ReplicatedStorage.Wave.Value
-- For the server: local wave = 0
wave = wave + 1
-- For the server: local wave = wave + 1 --> 1

But it won't change the value, to do this you have to have the variable as an object and change the objects value like this

local wave = game.ReplicatedStorage.Wave
wave.Value = wave.Value + 1

Hope this helped, if you have any more questions, just ask :)

0
Thank you :) figo30 9 — 6y
0
Np :) User#20388 0 — 6y
Ad

Answer this question