✓ Accepted answer
Hello, Your LocalScript is fine!
But if we want to know if the player had joined once and is returning, whe use something called DataStore, DataStore is a service that allows you to save a table or value forever!
Create a Script in ServerScriptService and call it whatever you want
If the script works, I'd highly appreciate it if you accept my answer, otherwise if it doesn't work, comment the problem and I'll try and fix it!
Script in ServerScriptService:
local PlayersService = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local joinDataStore = dataStoreService:GetDataStore("JoinDataStore")
PlayersService.PlayerAdded:Connect(function(player)
local isOnMenu = Instance.new("BoolValue")
isOnMenu.Name = "onMenu"
isOnMenu.Parent = player
local playerJoinData = nil
pcall(function()
playerJoinData = joinDataStore:GetAsync(player.UserId.."-joinData")
end)
if playerJoinData ~= nil then
isOnMenu.Value = false
print("Returning player")
else
isOnMenu.Value = true
print("New player")
end
end)
local bindableEvent = Instance.new("BindableEvent")
PlayersService.PlayerRemoving:Connect(function(player)
pcall(function()
joinDataStore:SetAsync(player.UserId.."-joinData", player.onMenu.Value)
end)
bindableEvent:Fire()
print("Saved!")
end)
game:BindToClose(function()
while #PlayersService:GetPlayers() > 0 do
bindableEvent.Event:Wait()
wait()
end
end)
2 comments
Also you can use badge and then test if player have it
That costs Robux