I'm trying to make a collision script where if a puck hits the wall, it goes the opposite direction. However, it's not even doing that. Here is the script:
local touched = true local puck = workspace.Puck.BodyVelocity.Velocity local X = puck.X local Y = puck.Y local Z = puck.Z script.Parent.Touched:Connect(function(part) if touched then if part.Name == "Puck" then puck = Vector3.new(-X, Y, Z) end end touched = false wait(1) touched = true end)
You wrote down that puck was equal to the puck's velocity as a variable. This would set the variable's velocity to (-X, Y, Z), but not the puck's velocity. Try this:
local debounce = false local puck = workspace.Puck.BodyVelocity local X = puck.X local Y = puck.Y local Z = puck.Z script.Parent.Touched:Connect(function(part) if part then debounce = false if part.Name == "Puck" then puck.Velocity = Vector3.new(-X, Y, Z) end wait(1) debounce = true end end)