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

Is it possible to get see when a table value changes?

Asked by 6 years ago

I am having a problem with when a table value you changes. I know you need to do it for when the object or table changes but I want it so only if the value changes.

local PlayerData = game:GetService("DataStoreService"):GetDataStore("PlayerData")
local DataRemote = game.ReplicatedStorage.DataStore.RemoteEvent
local FunctionModule = {}
local List = {}


--Player Added Functions
game.Players.PlayerAdded:connect(function(Player)
    local Level = 1
    local Experience = 0
    table.insert(List,Level)
    table.insert(List,Experience)
    local ID = Player.userId
    local Data = PlayerData:GetAsync(ID)
    PlayerData:SetAsync(ID,List)

    List[2].Changed:connect(function()
        if List[2] >= List[1]*10 then
            List[2] = List[2] - (List[1]*10)
            List[1] = List[1] + 1
        end
    end)
end)
--[[ERROR
22:11:02.177 - ServerScriptService.DataBase:17: attempt to index field '?' (a number value)
22:11:02.179 - Stack Begin
22:11:02.180 - Script 'ServerScriptService.DataBase', Line 17
22:11:02.182 - Stack End
--]]
0
The .Changed event can only fire and be applied to certain Roblox Objects. From what I see, you could just add IntValues to the Player, set those values to whatever you want and then call the .Changed event through those IntValues. PreciseLogic 271 — 6y
0
I am trying not to use IntValues because I am not trying to have players Find Information in scripts SilentGalaxZy 53 — 6y
0
I think you would have to add in this code whenever you change the value - you can't really do anything like this with simple integers. TheDeadlyPanther 2460 — 6y

Answer this question