Kampfkarren / Roblox

Scripts and stuff I wrote for Roblox. Documentation is little to none as these are just stuff I took from my game that I thought I could share.
https://kampfkarren.github.io/Roblox/
Other
284 stars 78 forks source link

DataStore2 is not a valid member of ServerScriptService "ServerScriptService" #137

Closed ajh123 closed 3 years ago

ajh123 commented 3 years ago

So this is my script that is also in ServerScripService

local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Workspace = game:GetService("Workspace")

local DataStore2 = require(ServerScriptService.DataStore2)
print("A")

-- Combine every key you use. This will eventually be the default, but for now read the "Gotchas" section to understand why we need this.
DataStore2.Combine("DATA", "money")

Players.PlayerAdded:Connect(function(player)
    local moneyStore = DataStore2("money", player)

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"

    local money = Instance.new("NumberValue")
    money.Name = "Money"
    money.Value = moneyStore:Get(1000) -- The "1000" means that by default, they'll have 1000 money
    money.Parent = leaderstats

    moneyStore:OnUpdate(function(newPoints)
        -- This function runs every time the value inside the data store changes.
        money.Value = newPoints
    end)

    leaderstats.Parent = player
end)

As you can see from this image both DataStore2 and my Money script are in there. also the other one does not affect this. So why is DataStore2 is not a valid member of ServerScriptService

Kampfkarren commented 3 years ago

I don't know from the given information, but there's basically no way this is a DataStore2 bug.

ajh123 commented 3 years ago

Fixed : the script needed to be Archivable