Making a ragdoll script. I have a server script looking for 2 events, ragdoll and unragdoll. I have them being called in a localscript. This isnt working, Im not getting any errors except the prints not showing up. Any help?
Server Script
--Variables--
local Players = game:GetService("Players")
local RagdollEvent = game.ReplicatedStorage.RemoteEvents.Ragdoll
local UnRagdollEvent = RagdollEvent.Parent.UnRagdoll
local throw = game:GetService("ReplicatedStorage").RemoteEvents.throw
--Ragdoll script--
RagdollEvent.OnServerEvent:Connect(function(player)
for i,v in pairs(player:GetDescendants()) do
if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
local Socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = v.Part0
a2.Parent = v.Part1
Socket.Parent = v.Parent
Socket.Attachment0 = a1
Socket.Attachment1 = a2
a1.CFrame = v.C0
a2.CFrame = v.C1
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
v:Destroy()
end
end
player.Humanoid.RequiresNeck = false
player.Character.Humanoid.Sit = true
print("Ragdolled")
end)
--Unragdoll script--
UnRagdollEvent.OnServerEvent:Connect(function(player)
for i,v in pairs(player:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v.UpperAngle = 0
v.TwistUpperAngle = 0
v.TwistLowerAngle = 0
local Joints = Instance.new("Motor6D",v.Parent)
Joints.Part0 = v.Attachment0.Parent
Joints.Part1 = v.Attachment1.Parent
Joints.C0 = v.Attachment0.CFrame
Joints.C1 = v.Attachment1.CFrame
v:Destroy()
end
end
player.Character.Humanoid.Sit = false
print("Unragdolled")
end)
Local Script
throw.OnClientEvent:Connect(function() --this is being called from another client
local player = Players.LocalPlayer
RemoteEvents.Ragdoll:FireServer(player)
RemoteEvents.UnRagdoll:FireServer(player)
end)
I believe that in the local script that there is an extra end, unless there are other things that aren’t being shown.
throw.OnClientEvent:Connect(function() --this is being called from another client
local player = Players.LocalPlayer
RemoteEvents.Ragdoll:FireServer(player)
RemoteEvents.UnRagdoll:FireServer(player)
end)
To add, are you sure that anything that is inside the local script is true if it’s under a logic statement?
throw.OnClientEvent:Connect(function()
local player = Players.LocalPlayer
local HRP = player.Character:FindFirstChild("HumanoidRootPart")
if not Ragdoll then
CAS:BindAction( --no movement
FreezeAction,
function()
return Enum.ContextActionResult.Sink
end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
local targetanim = player.Character:WaitForChild("Humanoid"):LoadAnimation(Target)
targetanim:Play()
wait(targetanim.length)
RemoteEvents.Ragdoll:FireServer(player)
Ragdoll = true
local z = Instance.new("BodyVelocity", player.Character:WaitForChild("HumanoidRootPart"))
z.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
z.Velocity = -HRP.CFrame.LookVector*75 + Vector3.new(0,50,0)
wait(0.4)--duration
z:Destroy()
wait(3)
RemoteEvents.UnRagdoll:FireServer(player)
CAS:UnbindAction(FreezeAction)--you can move now
wait(0.1)--delay
Ragdoll = false
end
end)
It sets false at the beginning of the script, i just sent everything in the function. Everything is properly initialized n stuffs. Looking at it again I mustve screwed with some instantiation with the remote events. This is what I got from the top if this looks sketch to you
local Players = game:GetService("Players")
local RemoteEvents = game.ReplicatedStorage.RemoteEvents
local CAS = game:GetService("ContextActionService")
local FreezeAction = "freezeMovement"
local throw = RemoteEvents.throw
Ragdoll = false
I just ended up removing the if statement, it ended up being redundant, Im not getting the issue anymore however
ragdoll still isnt working
I guess Ill have to debug the heck out of this one, if youd like to help more that would be cool but I can handle most of this on my own