Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PushHandler = {}
- local Debris = game:GetService("Debris")
- local Players = game:GetService("Players")
- local Ragdoll = require(game.ServerScriptService:WaitForChild("RagdollModule"))
- function PushHandler.PushPlayer(tool, player, target, mouseCFrame, damage, reload, ragdollReload)
- if not tool.Enabled then return end
- tool.Enabled = false
- local targetChar = target and target.Parent
- if not targetChar then return end
- local humanoid = targetChar:FindFirstChildWhichIsA("Humanoid")
- local root = targetChar:FindFirstChild("HumanoidRootPart")
- if humanoid and root and humanoid.Health > 0 then
- local force = tool:FindFirstChild("PushForce") and tool.PushForce.Value or 100
- root:SetNetworkOwner(nil)
- root.Velocity = mouseCFrame.LookVector * force
- humanoid:ChangeState(Enum.HumanoidStateType.Physics)
- local animate = targetChar:FindFirstChild("Animate")
- if animate then
- animate.Disabled = true
- end
- humanoid:ChangeState(Enum.HumanoidStateType.Physics)
- Ragdoll.EnableRagdoll(targetChar)
- task.delay(ragdollReload.Value, function()
- Ragdoll.DisableRagdoll(targetChar)
- end)
- local animate = targetChar:FindFirstChild("Animate")
- if animate then
- animate.Disabled = false
- end
- local tag = Instance.new("ObjectValue")
- tag.Name = "creator"
- tag.Value = player
- tag.Parent = humanoid
- Debris:AddItem(tag, 5)
- if not humanoid:FindFirstChild("DiedConnected") then
- local diedFlag = Instance.new("BoolValue")
- diedFlag.Name = "DiedConnected"
- diedFlag.Parent = humanoid
- humanoid.Died:Connect(function()
- local killerTag = humanoid:FindFirstChild("creator")
- if killerTag and killerTag.Value and killerTag.Value:FindFirstChild("leaderstats") then
- local killer = killerTag.Value
- local kills = killer.leaderstats:FindFirstChild("Kills")
- local achievements = killer:FindFirstChild("Achievements")
- if kills and achievements then
- kills.Value += 1
- for _, achievement in ipairs(achievements:GetChildren()) do
- local match = string.match(achievement.Name, "^Убить (%d+) человек$")
- if match then
- local requiredKills = tonumber(match)
- if requiredKills and kills.Value >= requiredKills and achievement:IsA("BoolValue") and not achievement.Value then
- achievement.Value = true
- end
- end
- end
- end
- end
- end)
- end
- humanoid:TakeDamage(damage.Value)
- local targetPlayer = Players:GetPlayerFromCharacter(targetChar)
- if targetPlayer then
- root:SetNetworkOwner(targetPlayer)
- end
- local sounds = tool:FindFirstChild("PushSounds")
- if sounds and #sounds:GetChildren() > 0 then
- local chosen = sounds:GetChildren()[math.random(1, #sounds:GetChildren())]:Clone()
- chosen.Parent = player.Character:FindFirstChild("HumanoidRootPart")
- chosen.PlayOnRemove = true
- chosen:Destroy()
- end
- local pushes = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("pushed")
- if pushes then
- pushes.Value += 1
- end
- end
- print(reload.Value)
- task.delay(reload.Value, function()
- tool.Enabled = true
- end)
- end
- return PushHandler
Advertisement
Add Comment
Please, Sign In to add comment