My script that is supposed to set the LimitsEnabled property to false on A BallSocketConstraint is pretty delayed. Now, the bone-breaking sound portion of the script works just fine however when the script actually does checks on the body part name and makes LimitsEnabled false, it is already past the sound, making it badly delayed.
Here is my code. (FOCUS ON LINE 13-14)
local soundTable = script.Sounds:GetChildren() -- yooo automated
script.Parent.Touched:Connect(function(hit)
if script.Parent.Velocity.Magnitude >= 120 then
if not hit:IsDescendantOf(script.Parent.Parent) and hit.Transparency <1 and hit.Locked == false then
local randomSound = soundTable[math.random(1, #soundTable)]
local clonedSound = randomSound:Clone()
clonedSound.Parent = script.Parent
clonedSound:Play()
wait(3)
clonedSound:Destroy()
if script.Parent.Name == "Left Leg" then
script.Parent.Parent.Torso.LLRagdollJoint.LimitsEnabled = false
end
end
end
end)
Any sort of help would be appreciated. Thanks!