HI! Could someone help me out? I am developing a game since a few days and i have a data saving script in ServerScriptService. The problem is, everytime i join my game the script disappears :/ This is the script: local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player) local CurrentOrb = game.ReplicatedStorage.CurrentOrb
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-CurrentOrb")
end)
if success then
CurrentOrb.Value = data
else
print("There was an error whilst getting your data, sorry :(")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-CurrentOrb",game.ReplicatedStorage.CurrentOrb.Value)
end)
if success then
print("Player Data saved")
else
print("There was an error when saving data")
warn(errormessage)
end
end)

1 comment
There shouldn't be a problem, you just can't view ServerScriptService in game because you are on the client. If you go to the test tab and switch to the server, the script will appear.