How to make an object fall until it hits something

local P1 = script.Parent
local P2 = workspace.P2

local Difference = (P2.Position-P1.Position)
local Distance = Difference.Magnitude
local direction = Difference.Unit


local Start = P1.Position
local ExpectedTime = 5

local AlphaTime = 0

local RunService = game:GetService("RunService")

local ended = false
local StartTime = tick()

RunService.Heartbeat:Connect(function(deltaTime)
	AlphaTime = tick()-StartTime
	if AlphaTime <= ExpectedTime then
		P1.Position = Start + direction*(Distance/ExpectedTime*AlphaTime)
	elseif not ended  then
		ended = true
		print(AlphaTime,"ellapsed time")
	end
end)

Sorry for a messy script, but whatever.

What is the P1 and P2 part of the script?

parts in the workspace
image

Hi, what I would do was spawn it in, tweenservice it to wherever it will go if it hits nothing, then after starting the tweenservice, wait for its touched event, once it touches, stop the tweenservice, and then have another tween that puts it down by like another 2 studs

It works as intended, thanks!! :slight_smile: