I'm trying to figure out how to delete a part that has been named after the user's id. I'm currently using FindFirstChild to find the id, however I cannot find how to delete it/Destroy().
local player = game.Players.LocalPlayer.UserId -- localplayer's id
local playername = game.Players.LocalPlayer.Name -- localplayer's name
local car = game.ReplicatedStorage.Cars.PoliceCar -- location of car
local clonedcar = car:Clone()-- clones car
function SpawnCar()
clonedcar.Name = player -- changes name of car to localplayer's id
clonedcar.VehicleSeat.Owner.Name = playername -- changes the owner of the car to the player's name
clonedcar.Parent = game.Workspace -- moves car to workspace
end -- everything above here works fine.
script.Parent.MouseButton1Click:connect(function() -- on button click
if game.Workspace:FindFirstChild(player) == nil then -- if car doesn't exist then
SpawnCar() -- spawn new car
else
-- stuck here.
end
end)
