I’m creating a badge that is to be assigned to the player upon leaving the game, the issue is, is by the time they have left, the game can no longer assign the badge to them.
Error msg:
Any workarounds for this?
I’m creating a badge that is to be assigned to the player upon leaving the game, the issue is, is by the time they have left, the game can no longer assign the badge to them.
Error msg:
Any workarounds for this?
Did you assign the function through this line of code?
Players.PlayerRemoving:Connect("The function that gives badge")
-- if one player on the server
game:BindToClose("The function that gives badge")
If you did, then I dunno.
Hope this helps!
I used the first function you mentioned, not the second one. How do you use the second one?
BindToClose may be the way to go with this … you could also give the badge when they log in.
This was a terrible reply … forget I said this
Problem here I think is a badge needs to do too many things even show you the badge was won on screen. Too much to pull off in the limited time you have after they leave.
yeah but how do I implement this
So, you should put this line of code at the end of script(to make sure it’s not gonna break anything), and if you have a name for your “give badge” function, just paste it in the brackets as shown here:
If it doesn’t work, try to copy the script on the screenshot and change this function:
function ServerShutdown()
if RunService:IsStudio() then
return
end
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(function()
PlayerLeaving(player) --this function, change it
end)
end
end
game:BindToClose(ServerShutdown)
I think that’s gonna work
But this is for server shutdown correct? I’m looking at if just one player leaves the game independently.
Yes it is … Maybe a task.spawn would work. I would just give the badge at the log in.
You need all 2 functions be here, because it’s not gonna work if 1 player on the server and there is no server shutdown function, because this function will prevent server from shutting down too early to not initialize the first actual badge giving function