Hello, I'm making an obby with teams (since it's easier for me) and I've come across an error. It shows up with:

Frame: 1

What: Main

Line No. 5

Source: ServerScriptService

In the Call stack.

Can someone assist me in fixing this? Thank you.

local playerService = game:GetService("Players") 
local datastoreService = game:GetService("DataStoreService")
local teams = game:GetService("Teams") -- teams are in here

local playersTeamDatastore = datastoreService:GetDatastore("Team")

playerService.PlayerAdded:Connect(function(player)
    local playerTeam = playersTeamDatastore:GetAsync(player.UserId)
    if playerTeam and teams:FindFirstChild(tostring(playerTeam))  then
        player.Team = teams:FindFirstChild(tostring(playerTeam))
    end
end)

playerService.PlayerRemoving:Connect(function(player)
    local playerTeam = player.Team 
    playersTeamDatastore:SetAsync(player.UserId, playerTeam)
end)

Error: 08:50:05.143 - GetDatastore is not a valid member of DataStoreService

2 comments

0

You need to give us an error, this debug pop-up doesn't show an error, Please check the output and edit the post showing what the error is.

0

08:50:05.143 - GetDatastore is not a valid member of DataStoreService