local D local n local X local b=false script.RepairChannel.OnServerEvent:Connect(function(J,r,G)local e=(game:GetService("\080\108\097\121\101\114\115")):GetPlayerFromCharacter(script.Parent.Parent)if e==J then X=J if r~=nil then n=G D=n.Parent.Parent.Parent.Engine script.Internal:Fire()else b=true end end end)while true do b=false script.Internal.Event:Wait()while wait(.5)do local D=n.Parent.Parent.Parent.Engine local J=(script.Parent.Handle.Position-D.Position).Magnitude local r=D.Velocity.Magnitude if b or J>50 or r>3 or script.Parent.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")==nil or n.Value>=100 then script.RepairChannel:FireClient(X)n=nil break else n.Value=math.min(n.Value+1,100)end end end
-- send nil to client to mark repair cancelled

local repairTarget
local repairingValue

local apparentHolder

local requestStop = false

script.RepairChannel.OnServerEvent:Connect(function(plr, engine, valObj)
	local holder = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)

	if holder == plr then
		apparentHolder = plr

		if engine ~= nil then
			repairingValue = valObj
			repairTarget = repairingValue.Parent.Parent.Parent.Engine

			script.Internal:Fire()
		else
			requestStop = true
		end
	end
end)

while true do
	requestStop = false
	script.Internal.Event:Wait()

	while wait(0.5) do
		local engine = repairingValue.Parent.Parent.Parent.Engine
		local dist = (script.Parent.Handle.Position - engine.Position).Magnitude
		local vel = engine.Velocity.Magnitude

		if
			requestStop
			or dist > 50
			or vel > 3
			or script.Parent.Parent:FindFirstChildOfClass("Humanoid") == nil
			or repairingValue.Value >= 100
		then
			script.RepairChannel:FireClient(apparentHolder)

			repairingValue = nil
			break
		else
			repairingValue.Value = math.min(repairingValue.Value + 1, 100)
		end
	end
end
