Skip to content

Commit 4fa5028

Browse files
committed
Fix ancestry changed firing when a player joins
1 parent a11b725 commit 4fa5028

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

DataStore2.module.lua

+1
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ function DataStore2:__call(dataStoreName, player)
724724

725725
local playerLeavingConnection
726726
playerLeavingConnection = player.AncestryChanged:Connect(function()
727+
if player:IsDescendantOf(game) then return end
727728
playerLeavingConnection:Disconnect()
728729
dataStore:Save()
729730
event:Fire()

Tests/tests/DataStore2.spec.lua

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ return function()
2525

2626
local fakePlayer = {}
2727
fakePlayer.AncestryChanged = playerRemovingEvent.Event
28+
fakePlayer.IsDescendantOf = function() return false end
2829
fakePlayer.UserId = 156
2930
setmetatable(fakePlayer, {
3031
TYPEOF_HACK = "Instance",

0 commit comments

Comments
 (0)