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

Another Data Store Error 'Unknown Global 'data'?

Asked by 8 years ago

In this data is labeled as unknown. But why? I know it needs a local data = but what do I define it as?

local key = 'weps'  
local exclude = {  
    'GameMusicHuman, GameMusicInfected, LobbyMusic, CamControl, NoNames, ToggleFlashlight, ToggleSound'; 
}  

game.Players.PlayerAdded:connect( 
function(p) 
        local weps = data:GetAsync(p.userId..'_'..key) 
        if weps then 
            for _,v in pairs(weps) do 
                if game.ReplicatedStorage:FindFirstChild(v) then 
                    game.ReplicatedStorage[v]:clone().Parent = p.StarterGear 
                end  
            end 
        end  
        p.StarterGear.ChildAdded:connect( 
            function(c)  
                local tools = { } 
                for _,v in pairs(p.StarterGear:GetChildren()) do  
                    local add = true  
                    for _,c in pairs(exclude) do  
                        if v.Name ~= c.Name then 
                            add = false 
                        end 
                    end 
                    if add then 
                        table.insert(tools, v.Name) 
                    end 
                end 
                data:SetAsync(p.userId..'_'..key  (tools))
            end)     
        end
)

Answer this question