Need help with brick not respawning // attempt to perform arithmetic (mul) on instance and number

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Need help with brick not respawning after being knocked
  2. What is the issue? Include screenshots / videos if possible!
    I have a script where if a car collieds with the brick (script.Parent) the brick gets unanchored and has some momentum, so the brick flies. there is also an error when looking in F9 console saying ‘attempt to perform arithmetic (mul) on instance and number’ on line 14 (script.Parent.Velocity = Direction * Force) which i think is the issue
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes, however I don’t know how to convert a value to an instance or number
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local origpos = script.Parent.Position -- original position
local origorientation = script.Parent.Orientation -- original orientation

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChildWhichIsA('Humanoid') 
	print('contact')
	if humanoid then
		print('humanoid hit it')
	elseif hit.Parent:FindFirstChildWhichIsA('Model') or hit.Parent:FindFirstChildWhichIsA('Part') or hit.Parent:FindFirstChild('hitbox') == true then -- did a model,part or hitbox hit it?
		print('part hit it')
		script.Parent.Anchored = false
		local Direction = hit.Parent:FindFirstChildWhichIsA('Model') or hit.Parent:FindFirstChildWhichIsA('Part') or hit.Parent:FindFirstChild('hitbox').CFrame.LookVector
		local Force = 10
		script.Parent.Velocity = Direction * Force
		wait(5)
		script.Parent.Velocity = 0
		script.Parent.Position = origpos
		script.Parent.Orientation = origorientation
		script.Parent.Anchored = true
		wait(5)
	else
		print('what')
	end
end)

image

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

In this line, two of the three possibilities for Direction is an instance, which can’t be multiplied by a number. I think you’re forgetting to get the LookVector for these options.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.