My entire script has just stopped working and I have no idea why please help.
local dss = game:GetService("DataStoreService")
local module = {}
game.Players.PlayerAdded:Connect(function(plr)
--Trainer Name
local name = Instance.new("StringValue")
name.Parent = plr
name.Name = "TrainerName"
name.Value = dss:GetDataStore("PlrName"):GetAsync(plr.userId) or ""
print(name.Value)
game.ReplicatedStorage.Events.SetPlayerName:FireClient(plr, name.Value)
--leaderstats
local leaderstats = Instance.new("Folder")
leaderstats.Parent = plr
leaderstats.Name = "leaderstats"
local badges = Instance.new("IntValue")
badges.Parent = leaderstats
badges.Name = "Badges"
badges.Value = dss:GetDataStore("PlayerBadges"):GetAsync(plr.userId) or 0
local pos = Instance.new("Vector3Value", plr)
pos.Name = "Position"
plr.CharacterAdded:Connect(function(char)
while true do
wait(1)
pos.Value = char.PrimaryPart.Position
print(pos.Value)
end
end)
end)
game.ReplicatedStorage.Events.LoadGame.OnServerEvent:Connect(function(player)
module.LoadData(player)
end)
module.LoadData = function(plr)
if dss:GetDataStore("PlayerPosition"):GetAsync(plr.userId) then
game.ReplicatedStorage.Events.LoadGameResponse:FireClient(plr)
plr.Character.PrimaryPart.Position = Vector3.new(dss:GetDataStore("PlayerPosition"):GetAsync(plr.userId).x,dss:GetDataStore("PlayerPosition"):GetAsync(plr.userId).y,dss:GetDataStore("PlayerPosition"):GetAsync(plr.userId).z)
end
require(script.Parent.PlayerData).data.party = dss:GetDataStore("PlayerDataParty"):GetAsync(plr.userId).party or {}
for i, v in pairs(require(script.Parent.PlayerData).data.party) do
print(v.Name)
end
end
game.Players.PlayerRemoving:Connect(function(plr)
--Player Position
dss:GetDataStore("PlayerPosition"):SetAsync(plr.userId, {
x = plr.Position.Value.X,
y = plr.Position.Value.Y,
z = plr.Position.Value.Z
})
--PlayerData
local party = {}
for i, v in pairs(require(script.Parent.PlayerData).data.party) do
party['Index'..i] = v
wait()
end
dss:GetDataStore("PlayerDataParty"):SetAsync(plr.userId, {party = party})
end)
return module

3 comments
It was working earlier but randomly now it just stopped working
The script is in serverscriptservice and is a module script
Maybe you unpublished your game? You can't access datastores unless you do so. Sometimes it glitches and unpublishes itself, so you might wanna check.