Player removing not getting data

Hi,

I have an issue with my code, for some reason it sometimes gets the data and sometimes it doesn’t. It should print out the value of HouseSlot (object value) which is inside of the player (game.Players.(plr name)).

code:
local Players = game:GetService(“Players”)

Players.PlayerRemoving:Connect(function(plr)

print(plr.HouseSlot.Value)

end)

1 Like

Print strings only appear in the Studio Output

1 Like

Yea, I am testing it in studio. I am actually using the value to check something just put this in here as an example, the thing is that sometimes it prints the value and sometimes the value is nil.

Read this, it might be helpful: DataModel | Roblox Creator Documentation

1 Like

When testing in Studio PlayerRemoving isn’t fired (because the game closes too fast).

https://developer.roblox.com/en-us/api-reference/function/DataModel/BindToClose

Use BindToClose() instead.

1 Like

What Limited saidㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

1 Like

Thank you, I am sorry but I found out my mistake that was in a different code but I could not delete this post.