#Float Bug Glitch Upon Slap

1 messages · Page 1 of 1 (latest)

vital siloBOT
#

studio** You are now Level 1! **studio

sly phoenix
#

There is a bug when slapping someone. If they jump immediately after getting hit, they can float around during Ragdoll. Can someone please help me fix this bug? Thank you.

strange cove
#

can you send some code to show what you are doing to fling them

sly phoenix
strange cove
#

thats okay

sly phoenix
#

--// Services:
local Debris = game:GetService("Debris")
local services_cs = game:GetService("CollectionService")
local services_ps = game:GetService("PhysicsService")
local services_rns = game:GetService("RunService")
local services_plrs = game:GetService("Players")

--// References & Variables:
local event_onRagdolled = script.onRagdolled
local isServer = services_rns:IsServer()
local instancesData, this = {
["motors6D"] = {}
}, {}

--// Ragdoll Functions:
function getGroupId(name)
local success, groupId = pcall(services_ps.GetCollisionGroupId, services_ps, name)
return (success and groupId or nil)
end

function this:checkRunType(character, ragdolled)
local client = services_plrs:GetPlayerFromCharacter(character)
if (isServer and client) then
event_onRagdolled:FireClient(client, character, not ragdolled)
elseif (not isServer) then
event_onRagdolled:FireServer(character, ragdolled)
return 1
end
return
end

function this:createSockets(motor, ragdollFolder)
if (motor.Part0) then
if (motor.Part0.Name == "HumanoidRootPart") then
return
end
end
if (motor.Part1) then
if (motor.Part1.Name == "HumanoidRootPart") then
return
end
end
local att1, att2 = Instance.new("Attachment"), Instance.new("Attachment")
local socket = Instance.new("BallSocketConstraint")
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
socket.Restitution = 1
socket.MaxFrictionTorque = 0
socket.UpperAngle = 180
socket.TwistLowerAngle = -180
socket.TwistUpperAngle = 180
att2.CFrame = motor.C1
att1.CFrame = motor.C0
socket.Attachment1 = att2
socket.Attachment0 = att1
socket.Parent = ragdollFolder
att2.Parent = motor.Part1
att1.Parent = motor.Part0
instancesData["motors6D"][motor] = motor.Part0
motor.Part0 = nil
return
end

function this:createHitbox(basePart, ragdollFolder)
local hitbox = Instance.new("Part")
local weld = Instance.new("Weld")
hitbox.Size = basePart.Size * 0.65
hitbox.CanCollide = true
hitbox.Transparency = 1
hitbox.Material = Enum.Material.Neon
hitbox.Color = Color3.new(1,0,0)
weld.Part0 = basePart
weld.Part1 = hitbox
hitbox.Parent = ragdollFolder
weld.Parent = hitbox
return
end

#

function this:removeRagdollInstances(character)
this:checkRunType(character, true)
if (character) then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
local ragdollFolder = character:FindFirstChild("Ragdoll")
if (humanoid and humanoidRootPart and ragdollFolder) then
if (isServer) then
for _, descendant in pairs(character:GetDescendants()) do
if (descendant:IsA("BasePart")) then
services_ps:SetPartCollisionGroup(descendant, "Default")
else
local part0 = instancesData["motors6D"][descendant]
if (part0) then
instancesData["motors6D"][descendant] = nil
descendant.Part0 = part0
end
end
end
ragdollFolder:Destroy()
end
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
humanoid.PlatformStand = false
humanoid.AutoRotate = true
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
humanoidRootPart.CanCollide = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
end
end
return
end

function this:createRagdollInstances(character)
if (character) then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if (humanoid and humanoidRootPart and not character:FindFirstChild("Ragdoll")) then
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
humanoid.PlatformStand = true
humanoid.AutoRotate = false
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
humanoidRootPart.CanCollide = false
if (this:checkRunType(character, false)) then
return
end
local ragdollFolder = Instance.new("Folder", character)
ragdollFolder.Name = "Ragdoll"
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
for _, descendant in pairs(character:GetDescendants()) do
local accessory = descendant:FindFirstAncestorWhichIsA("Accessory")
local tool = descendant:FindFirstAncestorWhichIsA("Tool")
if (descendant:IsDescendantOf(humanoidRootPart) or accessory or tool or descendant == humanoidRootPart) then
continue
end
if (descendant:IsA("BasePart")) then
services_ps:SetPartCollisionGroup(descendant, "ragdollCollisionGroup")
this:createHitbox(descendant, ragdollFolder)
elseif (descendant:IsA("Motor6D")) then
this:createSockets(descendant, ragdollFolder)
end
end
end
end
return
end

--// Ragdoll Events:
services_cs:GetInstanceRemovedSignal("Ragdoll"):Connect(function(character)
this:removeRagdollInstances(character)
end)
services_cs:GetInstanceAddedSignal("Ragdoll"):Connect(function(character)
this:createRagdollInstances(character)
end)
if (not isServer) then
event_onRagdolled.OnClientEvent:Connect(function(character, ragdolled)
workspace.CurrentCamera.CameraSubject = (ragdolled and character.Head or character.Humanoid)
end)
end
if (isServer) then
event_onRagdolled.OnServerEvent:Connect(function(client, character, ragdolled)
if (client.Character ~= character) then
return
end
if (ragdolled) then
this:removeRagdollInstances(character)
else

#

this:createRagdollInstances(character)
end
end)
end
if (isServer and not getGroupId("ragdollCollisionGroup")) then
services_ps:CreateCollisionGroup("ragdollCollisionGroup")
services_ps:CollisionGroupSetCollidable("Default", "ragdollCollisionGroup", false)
end

--// Slapping Functions:
local function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 10)
Creator_Tag.Parent = humanoid
end

local function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end

local function CheckForReactions(Part, Projectile, IsCheck)
local AllPass = true
for i,v in pairs(Part:GetChildren()) do
if v.Name == "AttackReaction" and v:IsA("ModuleScript") then
local Result = require(v).React(game.Players:GetPlayerFromCharacter(script.Parent.Parent), Projectile)
if not Result then
AllPass = false
end
end
end
return AllPass
end

local Owner
local Debounce = false
local Attack = false

script.Parent.Equipped:Connect(function()
Owner = script.Parent.Parent
end)

local function Slap(Hit, OurChar)
Hit = Hit.Parent:WaitForChild("HumanoidRootPart")
script.Parent.Hand.Hit:Play()
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
local Power = script.Parent.Configuration.Power.Value
BV.Velocity = OurChar.HumanoidRootPart.CFrame.LookVector * Power + OurChar.HumanoidRootPart.CFrame.UpVector * Power
this:createRagdollInstances(Hit.Parent)
BV.Parent = Hit
game:GetService("Debris"):AddItem(BV, 0.05)
local Player = game.Players:GetPlayerFromCharacter(OurChar)
if Player then
local leaderstats = Player:FindFirstChild("leaderstats")
if leaderstats then
local Slaps = leaderstats:FindFirstChild("Slaps")
if Slaps then
Slaps.Value += 1
end
end
end
local EnemyHum = Hit.Parent:FindFirstChildOfClass("Humanoid")
if EnemyHum and Player then
UntagHumanoid(EnemyHum)
TagHumanoid(EnemyHum, Player)
end
wait(1)
this:removeRagdollInstances(Hit.Parent)
end

script.Parent.Activated:Connect(function()
if not Debounce then
Debounce = true
local Hum = script.Parent.Parent:FindFirstChildOfClass("Humanoid")
local Twice = false
spawn(function()
Attack = true
local Anim = Hum:LoadAnimation(script.Parent.Swing)
Anim:Play()
Anim:AdjustSpeed(3)
local Touching = workspace:GetPartsInPart(script.Parent.Hand)
for i,v in pairs(Touching) do
if v.Parent:FindFirstChildOfClass("Humanoid") then
Attack = false
if CheckForReactions(v.Parent, nil, false) then
Slap(v, Owner)
end
break
end
end
wait(0.4)
if not Twice then
Attack = false
end
end)
script.Parent.Activated:Once(function()
Twice = true
end)
wait(script.Parent.Configuration.SlapCooldown.Value)
Debounce = false
end
end)

script.Parent.Hand.Touched:Connect(function(Hit)
if Attack and Hit.Parent ~= script.Parent.Parent and Hit.Parent ~= script.Parent then
local Hum = Hit.Parent:FindFirstChildOfClass("Humanoid")
if Hum then
Attack = false
if CheckForReactions(Hit.Parent, nil, false) then
Slap(Hit, Owner)
end
end
end
end)

#

This should be the whole thing.

#

It’s been about a month now trying to patch it haha.

strange cove
#

oh hah

vital siloBOT
#

studio** You are now Level 4! **studio

strange cove
#

I'll check it out in a min

sly phoenix
strange cove
#

try changing these

#

It might've been because the sockets were causing the player to constantly bounce up forever

#

feel free to mess with the max friction variable as necessary

#

but I just looked up how ballsockets work cuz I lowkey never used these before

strange cove
#

also, I reccomend using LinearVelocity as opposed to bodyvelocity, since bodyvelocity is deprecated

sly phoenix
#

Tysm, just got it working!

vital siloBOT
#

studio** You are now Level 2! **studio