Hello fellow devs i need help with my plane game

so i am working on a plane game with planes you can destroy by flying it into walls and i want to make the physics realistic like if one of my propeller breaks or one of my wings breaks the plane stops flying but ive tried much and i dont know what to do here is some of my script it also counts when the wing is detected to fall off

local Players = game:GetService("Players")

local function handleMissingWings()
    for _, player in ipairs(Players:GetPlayers()) do
        print("Checking wings for player:", player.Name)
        local character = player.Character
        if character then
            local humanoid = character:FindFirstChildOfClass("Humanoid")

            if humanoid and humanoid.SeatPart then
                local planeModel = humanoid.SeatPart.Parent

                if planeModel and planeModel:IsA("Model") then
                    local Wing1 = planeModel:FindFirstChild("Wing1")
                    local Wing2 = planeModel:FindFirstChild("Wing2")

                    if not (Wing1 and Wing2) then
                        print("Wings missing, initiating fall for player:", player.Name)
                        -- Wings are missing, forcefully stop the plane
                        local body = planeModel:FindFirstChild("Body")
                        if body and body:IsA("BodyVelocity") then
                            body:Destroy()
                        end
                        local bodyVelocity = Instance.new("BodyVelocity", body)
                        bodyVelocity.Velocity = Vector3.new(0, -30, 0)  -- Set a downward velocity (adjust as needed)
                    end
                end
            end
        end
    end
end

while true do
    handleMissingWings()
    wait(1)  -- Check every second (adjust as needed)
end

this script only works when you have your wing off and land the plane and jump out and jump in the plane again than it does work because it doesn’t let you go up

btw this is not the full script only a tiny piece that detects the wing and it should make the flying of the plane stop but it doesn’t and i need help while it does detect it

You could possibly try changing the script so that when a propeller is destroyed, it applies the force. If you choose to do this then this may be useful:
Destroying (Event) - documentation

In addition, you could try adding a ObjectValue inside of the player object to represent the plane of the player as this would allow you to check without requiring a character and it could prevent any possible issues with the humanoid.

Hope this helps :slight_smile:

it did something i updated my script and now when my wing/propeller fell off than the player got deleted and my screen froze and it gave me a bunch of errors at the end because i have a script that breaks parts of the plane and 5 seconds later the parts that fell gets removed from workspace and thats all the errors i got

Try adding a debounce so that the event can only fire once. This may help provent the screen from freezing as it won’t repeat the process too often.

i am trying but it doesnt do anything like i added a feature that destroys the seat when my wing gets broken but when the seat gets destroyed my whole screen freezes and it doesnt focus the player anymore like ive tried this script this is my full serverscript

,
– ServerScriptService.Script

local ServerStorage = game:GetService(“ServerStorage”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Players = game:GetService(“Players”)

local spawnPlaneEvent = ReplicatedStorage:WaitForChild(“SpawnPlaneEvent”)
local fixCameraEvent = ReplicatedStorage:FindFirstChild(“FixCameraEvent”)
if not fixCameraEvent then
fixCameraEvent = Instance.new(“RemoteEvent”)
fixCameraEvent.Name = “FixCameraEvent”
fixCameraEvent.Parent = ReplicatedStorage
end

local lastSpawnedPlanes = {}

local function cloneModel(original)
local clone = original:Clone()

-- Ensure all parts of the model are descendants
for _, part in pairs(clone:GetDescendants()) do
	if part:IsA("BasePart") then
	end
end

return clone

end

local function setModelCFrame(model, position)
local offset = Vector3.new(5, -5, 0) – You can adjust this offset as needed

local primaryPartName = "Seat" -- Replace with the actual name
local primaryPart = model:FindFirstChild(primaryPartName)

if primaryPart then
	primaryPart.CFrame = CFrame.new(position + offset)
else
	warn("PrimaryPart not found in the model.")
end

end

local function fixCamera(player)
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass(“Humanoid”)
if humanoid and humanoid.SeatPart then
humanoid.SeatPart:Destroy()
end
end
end

spawnPlaneEvent.OnServerEvent:Connect(function(player)
local character = player.Character
if character then
local lastSpawnedPlane = lastSpawnedPlanes[player]

	if lastSpawnedPlane then
		lastSpawnedPlane:Destroy() -- Remove the last spawned plane
	end

	local humanoid = character:FindFirstChildOfClass("Humanoid")

	if humanoid then
		local planeModel = cloneModel(ServerStorage:WaitForChild('Plane'))
		planeModel.Name = "Plane"
		planeModel.Parent = workspace

		setModelCFrame(planeModel, humanoid.Parent.PrimaryPart.Position)

		lastSpawnedPlanes[player] = planeModel -- Update the last spawned plane for the player
	end
end

end)
fixCameraEvent.OnServerEvent:Connect(fixCamera)
local function handleMissingWings()
for _, player in ipairs(Players:GetPlayers()) do
print(“Checking wings for player:”, player.Name)
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass(“Humanoid”)

		if humanoid and humanoid.SeatPart then
			local planeModel = humanoid.SeatPart.Parent

			if planeModel and planeModel:IsA("Model") then
				local Wing1 = planeModel:FindFirstChild("Wing1")
				local Wing2 = planeModel:FindFirstChild("Wing2")

				if not (Wing1 and Wing2) then
					print("Wings missing, initiating fall for player:", player.Name)
					-- Wings are missing, forcefully stop the plane
					local body = planeModel:FindFirstChild("Body")
					if body and body:IsA("BodyVelocity") then
						body:Destroy()
					end
					local bodyVelocity = Instance.new("BodyVelocity", body)
					bodyVelocity.Velocity = Vector3.new(0, -30, 0)  -- Set a downward velocity (adjust as needed)

					-- Reset player's control only if they are still in the seat
					if humanoid.SeatPart:IsA("Seat") and humanoid.SeatPart.Occupant == humanoid then
						humanoid.SeatPart:Destroy()
						-- Reset the camera
						humanoid.CameraMaxZoomDistance = 0
						humanoid.CameraMinZoomDistance = 0
					end
				end
			end
		end
	end
end

end
while true do
handleMissingWings()
wait(1) – Check every second (adjust as needed)
end
,

can anyone help because i have no idea of what to do