I am currently making a hockey game using BodyVelocity as the main mechanic for shooting and have encountered a bug that you can shoot through the net and score a goal or shoot through the arena.
Here’s the server script code involving the bodyvelocity.
script.Parent.Equipped:Connect(function()
script.Parent.SE.OnServerEvent:Connect(function(plr,power,mhp,mhv) -- plr = the player, power = number from 1-100 on how fast the puck shoots, mhp = mouse hit position, and mhv = mouse hitvector
local force = Instance.new("BodyVelocity")
force.MaxForce = Vector3.new(1,1,1) * math.huge
local power2 = power
if power >= 60 then
local test1 = mhv * power2
local test2 = test1 + Vector3.new(0,power / 5, 0)
force.Velocity = test2
else
force.Velocity = mhv * power2
end
force.P = math.huge
game.Workspace.Puck.Canpick.Value = false -- Seperate thing.
game.Workspace.Puck:FindFirstChild("Attatched"):Destroy() -- Seperate thing.
game.Workspace.Puck.CFrame = CFrame.lookAt(game.Workspace.Puck.Position, mhv)
game.Workspace.Puck.CanCollide = true
force.Parent = game.Workspace.Puck
game:GetService("Debris"):AddItem(force, power / 100)
wait(.75)
game.Workspace.Puck.Canpick.Value = true -- Seperate thing.
end)
end)
Here is a clip of the puck going through the net when shot.