Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why when player joins the function dont printing player joined and successful?

Bruh, once again i looking for help with my datastore bool script. After i changed the position of bool script, it dont saving the bool. But, when i joining, it dont print Player joining and success, after leaving, it prints player leaving, bind is loading and success x2, sometimes prints data queue is full.

wait(10)
local ds = game:GetService("DataStoreService")
local bool = ds:GetDataStore("ChristmasQuestSaving")
local RS = game:GetService("ReplicatedStorage")
--local changRemote = RS.ChanRem
game.Players.PlayerAdded:Connect(function(plr)
    print("Player Joining...")
            local boolValue = plr.Other.CQuestCompleted
    boolValue.Value = bool:GetAsync(plr.UserId) or false
    print("Successful!")
        end)
     
game.Players.PlayerRemoving:Connect(function(plr)
    print("Player Leaving...")
    local success, err = pcall(function()
        bool:SetAsync(plr.UserId, {plr.Other.CQuestCompleted.Value})
        print("Successful!")
        end)
end)

game:BindToClose(function()
    print("Bind is loading...")
    for i, v in pairs(game.Players:GetPlayers()) do
        local data = {
            ["QCA"] = v.Other.CQuestCompleted.Value,
        }
        bool:SetAsync(v.UserId, data)
        print("Successful!")
    end
end)

2 comments

0

You literally put a wait(10). Once the player join, the event doesn't even load yet until 10 seconds. It doesn't work since once it loads, the player is already loaded so it doesn't fire.

0

Bro, i litteraly put wait() into the joined function (because it cant find bool) changed something, AND IT WORKED! THANKS, I tired to fix it 2 days, changing it, adding new functions. Sadly i cant accept your answer because its a comment ;-;

1 answer

✓ Accepted answer

The answer is in the comment. Another way of fixing this issue is putting a :WaitForChild() when a player joins. For example:

game.Players.PlayerAdded:Connect(function(plr)
    plr:WaitForChild("Torso") --if it is R15, change 'Torso' to 'UpperTorso'
    print("Player Joining...")
end)

1 comment

0

Or you can put wait for child humanoid root part for all characters

This discussion is preserved as it was. New answers, comments, and votes are closed.