Hi there,
I am trying to strengthen my skills in scripting. so, I’m trying to make a script that if you press a key or press the GUI on-screen a local script fires a remote event to ragdoll players that collide with the right hand of the pusher.
I have figured most of it out.
However, the script works only when I use FireAllClients. Which as you probably know is not good since it triggers all players to ragdoll, which led me to use FireClient, but that just stops the script from working.
What’s even weirder is that there is no error output.
Here is the server script (R15 script that is inside of Push Script)
local Players = game:GetService("Players")
local char = script.Parent.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local config = script.Parent:WaitForChild("Settings")
local ShoveA = char[config.ShoveArm.Value.."Hand"]
RagdollStart = game.ReplicatedStorage.RagdollStart
RagdollEnd = game.ReplicatedStorage.RagdollEnd
local sound = config.ShoveSound
sound.Parent = ShoveA
local shoving = false
script.Parent.Shove.OnServerEvent:Connect(function()
local Track = char.Humanoid:LoadAnimation(config.ShoveAnimation)
Track:Play()
shoving = true
wait(5)
shoving = false
end)
function Shove(Pushed)
if shoving == true and Pushed.Parent:FindFirstChild("Humanoid") then
shoving = false
sound:Play()
local Victim = Pushed.Parent
local Victimragdoll = Victim:FindFirstChild("Humanoid")
RagdollStart:FireClient(Victim)
Victimragdoll.BreakJointsOnDeath = true
Victimragdoll.RequiresNeck= true
print("Ragdoll Start")
for _, v in pairs(Victim:GetDescendants()) do --ragdoll
if v:IsA("Motor6D") then
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v.Enabled = false
end
end
wait(5)
Victimragdoll.BreakJointsOnDeath = true
Victimragdoll.RequiresNeck= true
print("Ragdoll End")
for _,v in pairs(Victim:GetDescendants()) do --unragdoll
if v:IsA('Motor6D') then
v.Enabled = true
end
if v.Name == 'BallSocketConstraint' then
v:Destroy()
end
if v.Name == 'Attachment' then
v:Destroy()
RagdollEnd:FireClient(Victim)
print("PushCompleted")
end
end
end
end
ShoveA.Touched:Connect(Shove)
Here is the local script that is supposed to receive the FireClient (LocalRagdoll)
local RagdollServerEvent = game.ReplicatedStorage:WaitForChild("RagdollStart")
local RagdollClientEvent = game.ReplicatedStorage:WaitForChild("RagdollEnd")
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = script.Parent:WaitForChild("Humanoid")
game.ReplicatedStorage.RagdollStart.OnClientEvent:Connect(function()
print("Ragdoll Client Event")
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
humanoid.BreakJointsOnDeath = false
humanoid.RequiresNeck= false
end)
game.ReplicatedStorage.RagdollEnd.OnClientEvent:Connect(function()
print("UnRagdoll Client Event")
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
humanoid.BreakJointsOnDeath = true
humanoid.RequiresNeck = true
end)
The local script never receives the FireClient since it never prints “Ragdoll Client Event”
Also, if it helps this is how I have it organized in StarterCharacterScripts:
The PushScript handles just the press of a key or a GUI button which I’ve tested separately and it works on its own. It’s the FireClient inside of the server script that fails.
Thanks in advance for the help!