Make it so that when it gets launched it'll view that part when it gets flinged and then…
- User
Make it so that when it gets launched it'll view that part when it gets flinged and then it'll go back to normal cam.
--[[ WARNING: Heads up! This script has not been verified by ScriptBlox. Use at your own risk! Enhanced by [YourName] ]] -- Services local UserInputService = game:GetService("UserInputService") local Workspace = game:GetService("Workspace") local RunService = game:GetService("RunService") local Debris = game:GetService("Debris") local TweenService = game:GetService("TweenService") -- Configuration local BODY_VELOCITY_NAME = "FlingVelocity" local FLING_STRENGTH = 400 local FLING_DURATION = 0.5 -- Time in seconds to apply the fling smoothly local DEBOUNCE_TIME = 0.3 -- Time in seconds to prevent rapid inputs local ENABLE_VISUAL_FEEDBACK = true -- Set to false if you don't want visual indicators -- Variables local lastInputTime = 0 -- Helper Functions -- Creates a visual indicator for the fling (optional) local function createFlingIndicator(part, velocity) local indicator = Instance.new("Part") indicator.Size = Vector3.new(0.2, 0.2, 0.2) indicator.Position = part.Position indicator.Anchored = true indicator.CanCollide = false indicator.BrickColor = BrickColor.new("Bright red") indicator.Parent = Workspace local direction = velocity.Unit local distance = velocity.Magnitude * FLING_DURATION indicator.CFrame = CFrame.new(part.Position, part.Position + direction) * CFrame.new(0, 0, -distance / 2) -- Tween the indicator to scale over the fling duration local tweenInfo = TweenInfo.new(FLING_DURATION, Enum.EasingStyle.Quad, Enum.EasingDirection.Out) local tween = TweenService:Create(indicator, tweenInfo, {Size = Vector3.new(0.2, 0.2, distance)}) tween:Play() Debris:AddItem(indicator, FLING_DURATION) end -- Applies a smooth fling to the given part local function applySmoothFling(part, direction) local bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.Name = BODY_VELOCITY_NAME bodyVelocity.Velocity = Vector3.new(0, 0, 0) bodyVelocity.MaxForce = Vector3.new(0, 0, 0) bodyVelocity.Parent = part -- Tween the velocity to the desired direction smoothly local targetVelocity = direction * FLING_STRENGTH local tweenInfo = TweenInfo.new(FLING_DURATION, Enum.EasingStyle.Quad, Enum.EasingDirection.Out) local velocityTween = TweenService:Create(bodyVelocity, tweenInfo, {Velocity = targetVelocity, MaxForce = Vector3.new(math.huge, math.huge, math.huge)}) velocityTween:Play() -- Optional: Create a visual indicator if ENABLE_VISUAL_FEEDBACK then createFlingIndicator(part, targetVelocity) end -- Clean up the BodyVelocity after the fling duration Debris:AddItem(bodyVelocity, FLING_DURATION + 0.1) end -- Handles the fling logic based on input local function handleFling(part) local currentTime = tick() if currentTime - lastInputTime < DEBOUNCE_TIME then return -- Ignore inputs if within debounce time end lastInputTime = currentTime local lastInput = UserInputService:GetLastInputType() if lastInput == Enum.UserInputType.MouseButton2 then print("Launch initiated!") local direction = Workspace.CurrentCamera.CFrame.LookVector applySmoothFling(part, direction) elseif lastInput == Enum.UserInputType.MouseButton1 then print("Launch canceled!") -- Optionally, you can add logic to smoothly stop the fling if needed local existingVelocity = part:FindFirstChild(BODY_VELOCITY_NAME) if existingVelocity then existingVelocity:Destroy() end else print("No valid input detected for fling.") end end -- Monitors for added GrabParts models and sets up the fling mechanism Workspace.ChildAdded:Connect(function(model) if model:IsA("Model") and model.Name == "GrabParts" then local grabPart = model:FindFirstChild("GrabPart") if grabPart and grabPart:IsA("BasePart") then local weld = grabPart:FindFirstChild("WeldConstraint") if weld and weld:IsA("WeldConstraint") and weld.Part1 then local targetPart = weld.Part1 print("GrabPart found: " .. targetPart.Name) -- Set up listener for when the GrabParts model is removed local parentConnection parentConnection = model:GetPropertyChangedSignal("Parent"):Connect(function() if not model.Parent then handleFling(targetPart) parentConnection:Disconnect() end end) end end end end) -- Optional: Handle already existing GrabParts models on script start for _, model in ipairs(Workspace:GetChildren()) do if model:IsA("Model") and model.Name == "GrabParts" then local grabPart = model:FindFirstChild("GrabPart") if grabPart and grabPart:IsA("BasePart") then local weld = grabPart:FindFirstChild("WeldConstraint") if weld and weld:IsA("WeldConstraint") and weld.Part1 then local targetPart = weld.Part1 print("GrabPart found (existing): " .. targetPart.Name) -- Set up listener for when the GrabParts model is removed local parentConnection parentConnection = model:GetPropertyChangedSignal("Parent"):Connect(function() if not model.Parent then handleFling(targetPart) parentConnection:Disconnect() end end) end end end end - Assistant