Hello! I’m making a Jojo game where you get stands. I was programming an attack for the first stand, and I discovered that upon using the attack, the stand would delete itself at a random interval. Sometimes it doesnt even delete. Here are two examples of it happening:
One where it destroys:
https://gyazo.com/229c16e9e8bc4ae9983832168b6429d6
One where it doesnt:
https://gyazo.com/6e2f9389dedf0c088625e767c4499bd1
Here is the script I am using for the attack:
local UIS = game:GetService("UserInputService")
local char = game.Workspace:WaitForChild(player.Name)
local HRP = char:WaitForChild("HumanoidRootPart")
local vars = HRP:WaitForChild("vars")
local blocking = vars.blocking
local canattack = vars.canattack
local ragdolled = vars.ragdolled
local stand = player.leaderstats.stand
local hum = HRP:WaitForChild(stand.Value).Humanoid
local attackevent = game.ReplicatedStorage.attacking
local standhrp = HRP:WaitForChild(stand.Value).HumanoidRootPart
local barrageanim = game.Workspace.anims.BARRAGE
local barrage = hum:LoadAnimation(barrageanim)
ragdolled = false
blocking = false
local barraging = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if not blocking and canattack and not ragdolled and stand.Value == "Star Platinum" or "popbob" then
canattack = false
barraging = true
standhrp["stand weld"]:Destroy()
local offset = Vector3.new(0,0,2)
standhrp.CFrame = HRP.CFrame*CFrame.new(offset)
local weld = Instance.new("ManualWeld")
weld.Name = "stand weld"
weld.Part0 = HRP
weld.Part1 = standhrp
weld.C0 = standhrp.CFrame:inverse() * HRP.CFrame
weld.Parent = weld.Part1
barrage:Play()
local count = 4
while barraging == true do -- what happens during the barrage
Attack(1.2, 1,1,2)
wait(0.1)
count = count - 0.1
print(count)
if count < 0.1 then
barraging = false
end
end
weld:Destroy()
barrage:Stop()
standhrp.CFrame = HRP.CFrame * CFrame.new(2,-1,-2)
local weld = Instance.new("ManualWeld")
weld.Name = "stand weld"
weld.Part0 = HRP
weld.Part1 = standhrp
weld.C0 = standhrp.CFrame:inverse() * HRP.CFrame
weld.Parent = weld.Part1
wait(0.5)
canattack = true
end --what happens after the barrage
end
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E and barraging == true then
barraging = false
end
end)
end)
function Attack(damage, KB, stun, CD)
attackevent:FireServer(damage, KB, stun, CD)
end
The only thing I ever destroy is a weld that I created in a separate script. Thanks for any help!