local m local U local b local F=false script.RepairChannel.OnServerEvent:Connect(function(u,L,e)local Q=game.Players:GetPlayerFromCharacter(script.Parent.Parent)print(Q,u)if Q==u then b=u if L~=nil then U=e m=U.Parent.Parent.Parent.Engine script.Internal:Fire()else F=true end end end)while true do F=false script.Internal.Event:Wait()while wait(.5)do local m=U.Parent.Parent.Parent.Engine local u=(script.Parent.Handle.Position-m.Position).Magnitude local L=m.Velocity.Magnitude if F or u>50 or L>3 or script.Parent.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")==nil or U.Value>=100 then script.RepairChannel:FireClient(b)U=nil break else U.Value=math.min(U.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.Players:GetPlayerFromCharacter(script.Parent.Parent)

	print(holder, plr)

	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
