Hello, I was working on a tutorial for my game, and I wanted it to store User IDs when they join so that it doesn’t display the tutorial again. However, for some reason, this does not work. The following is the code I have.
local ds = game:GetService("DataStoreService"):GetDataStore("Tutorial")
game.Players.PlayerAdded:Connect(function(plr)
local new = Instance.new("BoolValue", plr)
new.Value = ds:GetAsync(plr.UserId) or true
new.Name = "New"
wait(60)
if plr.New.Value == true then
plr.PlayerGui:WaitForChild("TutorialGui").AskFor.Visible = true
end
end)
game.ReplicatedStorage:WaitForChild("Tutorial").OnServerEvent:Connect(function(plr, load)
if load == true then
wait(.5)
plr:LoadCharacter()
else
local root = plr.Character.HumanoidRootPart
root.CFrame = game.Workspace.TutorialTP.TP.CFrame
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local new = plr.New
new.Value = false
local succes, message = pcall(function()
ds:SetAsync(plr.UserId, new.Value)
end)
if succes then
else
warn(message)
end
end)
How would I fix this?