Roblox Scripting Speed Bag

I’m trying to script a speed bag the thing you punch and it swings back and forward. Any recommendations on how I should build it and make it work. Anything will help.

local speedBag = script.Parent
local hitbox = speedBag:FindFirstChild("Hitbox")

hitbox.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        for i = 1, 10 do
            speedBag.CFrame = speedBag.CFrame * CFrame.Angles(0, 0, math.rad(5))
            wait(0.05)
        end
    end
end)
4 Likes

uhhh idk how to fix itt
:frowning:

hnhjjgf

i probably wouldn’t use Roblox’s .Touched connection, as it’s usually buggy, and I would instead use something on the client like workspace:GetPartsBoundInBox(boxCFrame) and send the data to the server with remote events (yes this could be exploited but hopefully easy to patch).

Im not sure exactly what you would change if the physics were buggy, but Roblox’s RopeConstraints are a good second option if things don’t work out by using CFrame.

Yup I added a rope constraint it the physics are way better with it.

The current script is modifying the CFrame directly and I am pretty sure this can cause issues physics-based so instead maybe try Roblox physics engine. You can customize this to fit your needs: