Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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)
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. AProgrammR 398 — 3y
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 ;-; SashaPro336 47 — 3y

1 answer

Log in to vote
1
Answered by
KingDomas 153
3 years ago
Edited 3 years ago

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)
0
Or you can put wait for child humanoid root part for all characters SashaPro336 47 — 3y
Ad

Answer this question