Hello developers, So I’m workin on a hitbox. And I added a feature we’re your character ragdolls after being hit but theres a problem. When you walk into a opposited teamed player, you get ragdolled but not the opposite teamed player and I don’t really know why this is happening. Please tap in and help me please, Thank you.
Code:
-- Services --
local Players = game:GetService('Players')
local Replicated = game:GetService('ReplicatedStorage')
---
-- KEY Instances --
local Character = script.Parent.Parent
local Player = Players:GetPlayerFromCharacter(Character)
local Remotes = Replicated:WaitForChild('Remotes')
local Anims = Replicated:WaitForChild('Anims')
---
-- Values --
local CanTackle = true
---
-- Anims --
local Truck = Character.Humanoid:LoadAnimation(Anims:WaitForChild('BreakTackle'))
---
-- Scripts Valueables --
Character.Torso.Touched:Connect(function(Hit)
local Chance = math.random(1,3)
if Character:FindFirstChild('Football') then
local OpponentCharacter = Hit.Parent
local OpponentPlayer = Players:GetPlayerFromCharacter(OpponentCharacter)
if OpponentPlayer then
--
if OpponentPlayer.Team ~= Player.Team then
--
if CanTackle then CanTackle = false
if Chance == 1 then
print('Tackle')
Remotes.Tackle:FireServer('Tackle')
Remotes.Ragdoll:FireServer(Character,'Ragdoll')
Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
Remotes.Ragdoll:FireServer(OpponentCharacter,'Ragdoll')
OpponentCharacter.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
wait(1.5)
Remotes.Ragdoll:FireServer(Character,'Unragdoll')
Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
Remotes.Ragdoll:FireServer(OpponentCharacter,'Unragdoll')
OpponentCharacter.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
wait(1)
CanTackle = true
elseif Chance == 2 then
print('Stumble')
Remotes.Tackle:FireServer('Stumble')
Remotes.Ragdoll:FireServer(OpponentCharacter,'Ragdoll')
OpponentCharacter.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
Truck:Play()
Character.Humanoid.WalkSpeed = 12
wait(0.4)
Truck:Stop()
Character.Humanoid.WalkSpeed = 16
CanTackle = true
wait(1.5)
Remotes.Ragdoll:FireServer(OpponentCharacter,'Unragdoll')
OpponentCharacter.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
elseif Chance == 3 then
print('Fumble')
Remotes.Tackle:FireServer('Fumble')
Remotes.Ragdoll:FireServer(Character,'Ragdoll')
Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
Remotes.Ragdoll:FireServer(OpponentCharacter,'Ragdoll')
OpponentCharacter.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
wait(1.5)
Remotes.Ragdoll:FireServer(Character,'Unragdoll')
Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
Remotes.Ragdoll:FireServer(OpponentCharacter,'Unragdoll')
OpponentCharacter.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
wait(1)
CanTackle = true
end
end
end
end
end
end)
---
-- Downed --
for _,V in pairs(Character:GetChildren()) do
if V:IsA('Part') then
V.Touched:Connect(function(Hit)
if Hit.Name == 'Baseplate' and Player.Backpack:FindFirstChild("Main")["Tackle"].Value == true then
local Football = Character:FindFirstChild('Football')
if Football then
if CanTackle then CanTackle = false
print('Downed')
Remotes.Tackle:FireServer('Downed')
wait(1.5)
CanTackle = true
end
end
end
end)
end
end
---