I’m trying to make an animatronic model (NOT AN NPC) that spazzes from an “electrical shock” effect.
However, I do not like how the ball sockets do not have collision, and am trying to find a way to give them collision.
I have tried searching, but to no avail.
Code:
local Animatronic = workspace:WaitForChild("Animatronic")
local function ControlledShock(Animatronic)
for _, Motor6D in pairs(Animatronic:GetDescendants()) do
if Motor6D:IsA("Motor6D") then
local ShockPart = Motor6D.Parent
local NonShockable = Motor6D:GetAttribute("NonShockable")
if NonShockable == true then
continue
end
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = Motor6D.C0
a1.CFrame = Motor6D.C1
a0.Parent = Motor6D.Part0
a1.Parent = Motor6D.Part1
local Socket = Instance.new("BallSocketConstraint")
Socket.Attachment0 = a0
Socket.Attachment1 = a1
Socket.Parent = Motor6D.Part0
Motor6D.Enabled = false
coroutine.resume(coroutine.create(function()
while wait() do
ShockPart:ApplyImpulse(Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10)) * ShockPart.AssemblyMass * 2)
end
end))
end
end
end
ControlledShock(Animatronic)
Any help?