local owner = script.Parent.Parent.Parent.Owner.Value local ownerfound = game.Players:FindFirstChild(owner) local model = script.Parent.Parent.Parent.Model.Value repeat wait() until ownerfound == nil if ownerfound == nil then script.Parent.Parent.Parent:Destroy() end
this script is in a car. i am trying to make it destroy a car if its owner is not in the game. so it the owner is not found in the game then the car will be destroyed. it wont destroy the car when owner is not found. please can you help me its my first question on this website please someone help me with this
Try this:
local owner = script.Parent.Parent.Parent.Owner.Value local ownerfound = game.Players:FindFirstChild(owner) local model = script.Parent.Parent.Parent.Model.Value while wait() do game.Players.PlayerRemoving:connect(function(player) if player.Name = ownerfound then model:Remove() wait(0.1) end end) end --{ Basically what is happening is that once the player is leaving the game, it will check if that players name is the one that matches the owner name, if it is, then destroy the car. }--