Im building pickups into Team Death Match. I am trying to reset the crystal pickups as part of the LobbyStartResetKDServer script
The code runs without error, and produces good object references, but they are not changing state in game to isEnabled = true
CODE *****************************************************************
local ABGS = require(script:GetCustomProperty("API"))
local GOLD = World.FindObjectByName("Gold")
-- nil OnGameStateChanged(int, int, bool, float)
-- Handles resetting team scores when the game state switches to lobby
function OnGameStateChanged(oldState, newState, hasDuration, endTime)
if newState == ABGS.GAME_STATE_LOBBY and oldState ~= ABGS.GAME_STATE_LOBBY then
for _, player in pairs(Game.GetPlayers()) do
player.kills = 0
player.deaths = 0
player:SetResource("playerGold",0)
end
for _, Crystal in pairs(GOLD:GetChildren()) do
if Crystal ~= nil then
print(Crystal)
Crystal.isEnabled = true
end
end
end
What am I missing?