That error does not sound right.
There are 3 issues with line #7:
ball.CFrame = hit.Parent:FindFirstChild("HumanoidRootPart").CFrame.LookVector * CFrame.new(0, 5, -5)
1). You're using Instance:FindFirstChild inappropriately. FindFirstChild has the capacity to return nil, so when intending to use its return result, you must verify said result beforehand:
local X = Y:FindFirstChild("Z")
if X then
end
2). Vector3 * CFrame is an unsupported operation—see Vector3's available "Math Operations". The error you should have received, "invalid argument #1 (CFrame expected, got Vector3)", will have been risen from this contradiction.
3). After removing * CFrame.new(0, 5, -5), you will make an attempt to assign a Vector3 to a property that expects a CFrame. This cannot be done, and will raise another error.
The code you mean to write is:
X.CFrame = Y.CFrame * CFrame.new()
Furthermore, your debounce puts your callback out of commission. It's better to disconnect your RBXScriptConnection so the callback can be properly removed. For more information, see "Handling Events".
1 comment
This code is packed with contradictions.