Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why wont this script work?

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

1 answer

✓ Accepted answer

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. }--

2 comments

0

thanks for your answer although i figured it out but this was better then mine thank you

0

Glad I could help!

This discussion is preserved as it was. New answers, comments, and votes are closed.