Hi! I have this table and i’d like to set the “variable” in here to the value of an IntValue. How would i do this?
local items = {
I want this changed = 0,
I dont want this changed = 5
}
thanks!
Hi! I have this table and i’d like to set the “variable” in here to the value of an IntValue. How would i do this?
local items = {
I want this changed = 0,
I dont want this changed = 5
}
thanks!
IntValue:GetPropertyChangedSignal("Value"):Connect(function()
items["I want this changed"] = IntValue.Value
end)
Items[1].value = another value
Or Items[1] = value
Not 100% sure this works
Doesnt work, here’s the full script:
local items = {
["Nitro"] = 0
}
game.ReplicatedStorage.Events.Bought.OnClientEvent:Connect(function(price, name)
print("received event.")
print(name)
for i, v in pairs(script.Parent:GetChildren()) do
print("going trough...")
if v.Name == name then
print("v == name")
v.Amount.Value += 1
v.ItemAmount.Text = "Amount: "..v.Amount.Value
v.Amount:GetPropertyChangedSignal("Value"):Connect(function()
items[tostring(v.Name)] = v.Amount.Value
end)
game.ReplicatedStorage.Events.SyncItems:FireServer(items)
end
end
end)
You need to put this above that code
items[tostring(v.Name)] = v.Amount.Value
I don’t understand what you mean?
You need to run that once before as GetPropertyChangedSignal only fires when it changes
items[tostring(v.Name)] = v.Amount.Value
v.Amount:GetPropertyChangedSignal("Value"):Connect(function()
items[tostring(v.Name)] = v.Amount.Value
end)