I always keep reciving issues from my glove system, I’ve been fixing them lately. But the one I haven’t been able to crack down was the weird flying glitch.
Explaination
Whenever a player gets slapped, there is a chance that they will start flying around everywhere and they won’t stop until they get slapped.
Glove’s script
local targetHumanoidRP : BasePart = targetedplayer:WaitForChild("HumanoidRootPart")
local playerHumanoidRP : BasePart = player.Character:WaitForChild("HumanoidRootPart")
local targethumanoid : Humanoid = targetedplayer.Humanoid
-- If target's humanoid and player's humanoid was found
if targetHumanoidRP and playerHumanoidRP then
-- Creating BodyVelocity and BodyAngularVelocity
targetedplayer.Humanoid.WalkSpeed = 0
local targetedplayerinstance = game:GetService("Players"):GetPlayerFromCharacter(targetedplayer)
local velocity
local rot
velocity = Instance.new("BodyVelocity",targetedplayer.HumanoidRootPart)
velocity.MaxForce = Vector3.new(2,2,2) * math.huge
local dir = (targetedplayer.HumanoidRootPart.CFrame.Position - player.Character.HumanoidRootPart.Position).Unit
velocity.Velocity = Vector3.new(playerHumanoidRP.CFrame.LookVector.X * script.Parent.GloveStatsConfig.Power.Value, 1.5, playerHumanoidRP.CFrame.LookVector.Z * script.Parent.GloveStatsConfig.Power.Value)
rot = Instance.new("BodyAngularVelocity",targetedplayer.HumanoidRootPart)
rot.AngularVelocity = Vector3.new(1,2,1) * math.pi * 5
rot.MaxTorque = Vector3.new(2,5,2) * math.huge
rot.P = 10000 --used to be 5k
-- Makes player in a falling position, then ragdolls
targethumanoid.RequiresNeck = false
targetedplayer.PreventFlopping1.Disabled = false
targetedplayer.PreventFlopping2.Disabled = false
betterragdollmodule:Ragdoll(targetedplayer)
game:GetService("Debris"):AddItem(velocity, 0.7)
game:GetService("Debris"):AddItem(rot,0.7)
targethumanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
task.wait(4)
targetedplayer.PreventFlopping1.Disabled = true
targetedplayer.PreventFlopping2.Disabled = true
targethumanoid.RequiresNeck = true
targethumanoid.PlatformStand = false
-- Ragdolls player
betterragdollmodule:Unragdoll(targetedplayer)
betterragdollmodule:Unragdoll(targetedplayer)
targethumanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
script.Parent.GettingUpEvent:FireAllClients(targethumanoid)
-- If Ragdoll instances found, then repeat standing up, since in most cases target can ragdoll while standing
if targetedchar:FindFirstChild("Humanoid") then
local a = targetedchar
for _, instance in pairs(targetedchar:GetDescendants()) do
if instance:IsA("BallSocketConstraint") then
found = true
end
end
if found == nil then
script.Parent.GettingUpEvent:FireAllClients(targethumanoid)
else
repeat
wait()
betterragdollmodule:Unragdoll(targetedplayer)
until targetedchar.Parent.HumanoidRootPart.BallSocketConstraint.Parent == nil
betterragdollmodule:Unragdoll(targetedplayer)
script.Parent.GettingUpEvent:FireAllClients(targethumanoid)
found = nil
end
end
task.wait(0.5)
script.Parent.GettingUpEvent:FireAllClients(targethumanoid)
betterragdollmodule:Unragdoll(targetedplayer)
end