Hello everyone,
I have a small problem when it comes to updating a variable, and I cant seem to find a solution so I thought I’d ask here.
The problem is that when I try to update the variable, it simply won’t. It just stays the old value.
This might be some basic issue but I honestly cant get it figured.
Code:
-- Pulling data
local CurrentData = ReplicatedStorage.RemotesExternal.RequestData:InvokeServer()
local MicrophonesOwned = CurrentData[3]
function UpdateData()
local newData = ReplicatedStorage.RemotesExternal.RequestData:InvokeServer()
-- Printing "newData[3]" prints the table I need, now I want to apply it to the variable.
MicrophonesOwned = newData[3]
end
-- Assuming the data has updated on the server, and the client wants their data
-- We will run the UpdateData() function
UpdateData()
function Purchase()
print(MicrophonesOwned)
-- Prints the old values, instead of the new updated one. Why?
end
-- Assuming the player has pressed a button to purchase something, we run the Purchase() function
Purchase()