Don’t use Instance.new("Folder", plot), it’s a lot slower and can do some harm to your game, I would link a topic explaining this but I can’t find it, just use:
local folder = Instance.new("Folder")
folder.Name = "Offices"
folder.Parent = plot
local prompt = script.Parent
local appPlayer = nil
local plot = script.Parent.Parent.Parent.Parent
local players = game:GetService("Players")
local storage = game:GetService("ReplicatedStorage")
prompt.Triggered:Connect(function(player)
appPlayer = player
player.PlayerData.IsPlayerHavePlot.Value = true
script.Parent.Parent.Parent.Parent.Claimed.Value = true
script.Parent.Enabled = false
local office = storage.Models.Offices.OfficeLvl1
local clone = office:Clone()
clone.Parent = plot.Offices
local model = clone
model:MoveTo(plot.Position)
end)
players.PlayerRemoving:connect(function(player) -- This part
if player.Name == appPlayer.Name then
prompt.Enabled = true
script.Parent.Parent.Parent.Parent.Claimed.Value = false
plot.Offices:Destroy()
end
end)
You were attempting to compare a player instance with a player name (which is a string value) which would always end up as evaluating as false.