Character Electrocution Effect

Hello,

I’m trying to make a taser that stuns and electrocutes victims when shot. I’d like to implement a realistic (sort of) effect where each limb on the victim’s body sort of spasms in the way one would by getting electrocuted, although I’m not sure exactly how to do this. Here is an example video of what I want to happen:

I’ve tried using BodyGyros, BodyAngularVelocities, BodyPositions, on each limb of the victim’s body, but none of those seemed to work, or at least in the way I tried to do it. Also, I’d like to not use animations if possible, I want this to be done only using constraints. If anyone knows how I could achieve something like this, please let me know, thanks.

2 Likes

you can check my profile for a simple module I made for ragdolling but the main code is this:

local char = player.Character
			
wait()
char.Humanoid.BreakJointsOnDeath = false
char.HumanoidRootPart.CanCollide = false

for i, v in pairs(char:GetDescendants()) do		
	if v:IsA("Motor6D") then --this is just to add ball constraints
		local a0 = Instance.new("Attachment")
		local a1 = Instance.new("Attachment")

		a0.Name = "a0"
		a1.Name = "a1"a0.Parent = v.Part0
		a1.Parent = v.Part1

		a0.CFrame = v.C0
		a1.CFrame = v.C1

		local ball = Instance.new("BallSocketConstraint")
		ball.Name = "ball"
		ball.Parent = v.Parent
		ball.Attachment0 = a0
		ball.Attachment1 = a1
		ball.LimitsEnabled = true
		ball.TwistLimitsEnabled = true
		ball.Parent = v.Parent
		ball.Enabled = true --this just makes the character ragdoll
		char.Humanoid:ChangeState(Enum.HumanoidStateType.Physics) --makes it so their bodies are affected by physics and can't move
	end
end
2 Likes