Touched event firing too early?

This is a problem with roblox replication. Instead of using a .Touched event, I’d do something like:

local connection
connection = game:GetService"RunService".Heartbeat:Connect(function()
    local ray = Ray.new(part.Position, Vector3.new(0, -1, 0) * 3)
    local hitPart, hitPos = workspace:FindPartOnRay(ray)
    if hitPart and hitPart.CanCollide then
        part.CFrame = hitPos
        part.Anchored = true
        connection:Disconnect()
    end
end)
7 Likes