- What do you want to achieve? Keep it simple and clear!
Hello, so basically I am trying to make a new player join system
- What is the issue? Include screenshots / videos if possible!
when a new player joins the system will check their playergui if they have the “JoinBefore” Value that is stored in DataStore then the gui will not show. Otherwise when they finished or click on skip tutorial then the value will be created in their playergui. But the problem is when they left the game and the Value is being stored. The next day they come back and play the game they are on hold as new players.
local StringMsg = {"Hello, Welcome to Farmer Simulator! We have notice that you are new to the game!"}
local Datastore = game:GetService("DataStoreService"):GetDataStore("NewStore")
local NewPlr = Instance.new("IntValue")
game.Players.PlayerAdded:Connect(function(player)
local NewPlayerGui = player.PlayerGui:WaitForChild("NewPlayer")
local Frame = NewPlayerGui:WaitForChild("Frame")
if Frame.Visible == false and Frame:FindFirstChild(NewPlr.Name) then
NewPlayerGui.Name = "JoinBeforeValue"
print(player.Name .. " Welcome back!")
else
NewPlayerGui.Name = "NewPlayerValue"
Frame.TextLabel.Text = StringMsg[1]
Frame.Visible = true
print(player.Name .. " is new to the game!")
end
local Data
local success, err = pcall(function()
Data = Datastore:GetAsync(player.UserId, NewPlr.Value)
end)
if success then
print(player.Name .. " data has been successfully loaded into the game!")
else
print(player.Name .. " Data was not successfully loaded!")
end
Frame:WaitForChild("TextButton").MouseButton1Click:Connect(function()
Frame.Visible = false
NewPlr.Parent = NewPlayerGui
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local su, re = pcall(function()
Datastore:SetAsync(player.UserId, NewPlr.Value)
end)
if su then
print(player.Name .. " left the game saving data..")
warn("success! ~-~")
else
print("Warning:", string.upper(player.Name .. "left the game and the data was not saved successfully.. left the game and the data was not saved successfully.." .. re))
warn("Failed :'(")
end
end)
game:BindToClose(function()
for _,v in pairs(game.Players:GetPlayers()) do
local su, re = pcall(function()
Datastore:SetAsync(v.UserId, NewPlr.Value)
end)
if su then
warn("Developer has shut down the game or something unexpectly happened while trying to save player data " .. su)
else
warn("Warning:", string.upper("Developer has shut down the game or something unexpectly happened while trying to save player data" .. re))
end
end
end)
I felt really bad that I kept on coming back and asking for help on Devforum… As to like I’m not a very good scripter.