Insert text here.
- What do you want to achieve? Keep it simple and clear!
I have a gun system that includes a bullet hole system. When you shoot a humanoid’s limbs, it simply creates a gunshot wound where it hit.
I want there to be a sort of bleeding from the wound, which I want to achieve through a blood decal spawning and expanding where the bullet hole was created.
- What is the issue? Include screenshots / videos if possible!
The problem here is that while the bloodsplatter (which accompanies the gunshot wound* expands, the ragdoll freezes (primarily when the fatal shot was on the torso)
Here is a video of the issue, pause if you need to read:
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have only yet tried using a while function. While it partially works, it causes some horrible frame drops.
Here are the designated lines of code:
if raycast then
hitpos = raycast.Position
local debugpart = Instance.new("Part", workspace)
debugpart.Position = raycast.Position
debugpart.Size = Vector3.new(0.5, 0.5, 0.5)
debugpart.Material = Enum.Material.Neon
debugpart.Color = Color3.new(1, 0, 0.0156863)
debugpart.Anchored = true
debugpart.Transparency = 1
debugpart.CanCollide = false
debugpart.CanQuery = false
debugpart.Name = "Flesh"
debris:AddItem(debugpart, 4)
local falloffdam = statfolder.BaseDmg.Value - raycast.Distance / 3
local hum = raycast.Instance.Parent:FindFirstChild("Humanoid")
if hum then
local particlepuffclone = game.ReplicatedStorage.WeaponAssets.Particles.Blood.Puff:Clone()
local particlesplashclone = game.ReplicatedStorage.WeaponAssets.Particles.Blood.HorizontalSplat:Clone()
local particlecircleclone = game.ReplicatedStorage.WeaponAssets.Particles.Blood.BloodCircle:Clone()
particlepuffclone.Parent = debugpart
particlesplashclone.Parent = debugpart
particlecircleclone.Parent = debugpart
particlepuffclone:Emit(math.random(8, 19))
particlesplashclone:Emit(math.random(8, 19))
particlecircleclone:Emit(math.random(8, 19))
local hitsounds = game.ReplicatedStorage.WeaponAssets.HitSounds.Flesh.Hit:GetChildren()
local hitsoundsfatal = game.ReplicatedStorage.WeaponAssets.HitSounds.Flesh.Fatal:GetChildren()
local soundclonenon = hitsounds[math.random(1, #hitsoundsfatal)]:Clone()
soundclonenon.Parent = debugpart
soundclonenon:Play()
local bullethole = game.ReplicatedStorage.WeaponAssets.BulletHoles.Flesh:Clone()
bullethole.Parent = raycast.Instance.Parent
bullethole.Attachment.Position = Vector3.new(0,0,0)
bullethole.Position = raycast.Position
bullethole.CFrame = CFrame.new(bullethole.Position, bullethole.Position + raycast.Normal)
local fleshbloodfolder = game.ReplicatedStorage.WeaponAssets.BulletHoles.FleshBlood:GetChildren()
local fleshblood = fleshbloodfolder[math.random(1, #fleshbloodfolder)]:Clone()
fleshblood.Parent = bullethole
fleshblood.CFrame = bullethole.CFrame
local bloodweld = Instance.new("WeldConstraint", raycast.Instance)
bloodweld.Part0 = bullethole
bloodweld.Part1 = fleshblood
local bulletweld = Instance.new("WeldConstraint", raycast.Instance)
bulletweld.Part0 = raycast.Instance
bulletweld.Part1 = bullethole
bullethole:SetNetworkOwner(nil)
fleshblood:SetNetworkOwner(nil)
if raycast.Instance.Name == "Torso" then
hum:TakeDamage(falloffdam * 1.5)
if hum.Health < 1 then
local soundclone = hitsoundsfatal[math.random(1, #hitsoundsfatal)]:Clone()
soundclone.Parent = debugpart
soundclone:Play()
end
elseif raycast.Instance.Name == "Head" then
hum:TakeDamage(falloffdam * 10)
if hum.Health < 1 then
local soundclone = hitsoundsfatal[math.random(1, #hitsoundsfatal)]:Clone()
soundclone.Parent = debugpart
soundclone:Play()
end
elseif raycast.Instance.Name == "Left Arm" or raycast.Instance.Name == "Right Arm" or raycast.Instance.Name == "Left Leg" or raycast.Instance.Name == "Right Leg" then
hum:TakeDamage(falloffdam)
if hum.Health < 1 then
local soundclone = hitsoundsfatal[math.random(1, #hitsoundsfatal)]:Clone()
soundclone.Parent = debugpart
soundclone:Play()
end
end
local bloodexpand = tweenservice:Create(fleshblood, bloodtween, {Size = Vector3.new(math.random(7, 9)/ 10, math.random(7, 9)/ 10, 0.01)})
bloodexpand:Play()
bloodexpand.Completed:Connect(function()
bloodexpand:Destroy()
end)
bullethole.Attachment.BulletHoleBleeding.Enabled = false
end
end
If I do eventually find a solution, I will let everyone know.