Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't the part disappearing?

Asked by 7 years ago

I have the game.Debris:AddItem thing, so why isn't it working? Here's my script:

01local player = game.Players.LocalPlayer
02local Mouse = player:GetMouse()
03 
04game:GetService("UserInputService").InputBegan:connect(function(input,proc)
05    if  input.KeyCode == Enum.KeyCode.C then
06script.Disabled = true
07    local anim = Instance.new("Animation")
08anim.AnimationId = 'rbxassetid://864612571'
09local loadanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(anim)
10loadanim:Play()
11local x = Instance.new("Part", workspace)
12    x.Anchored = false
13    x.CanCollide = false
14    x.Parent = player.Character.RightHand
15    x.Material = "Neon"
View all 35 lines...

1 answer

Log in to vote
0
Answered by 7 years ago

Reading through it seems that you add the part to the debris service in an if statement

1if Hit.Parent:findFirstChild("Humanoid") and Hit.Parent.Humanoid ~= player.Character.Humanoid
2 
3    Hit.Parent.Humanoid:TakeDamage(
4    x:Destroy()
5    game.Debris:AddItem(x,0.8)
6 
7            end

This means that if the IF function doesn't fire either due to a coding error or any other reason, the part is not added to the debris service and will not dissapear.

Try adding a print() before it to see if it's actually firing.

1if Hit.Parent:findFirstChild("Humanoid") and Hit.Parent.Humanoid ~= player.Character.Humanoid
2 
3    Hit.Parent.Humanoid:TakeDamage(
4    x:Destroy()
5    game.Debris:AddItem(x,0.8)
6 
7    print("x added to debris.")
8 
9            end

I also noticed that you're using Destroy() on the part before adding it to the debris service. If this doesn't throw an error then chances are the entire IF statement isn't firing at all.

Add a buttload of prints wherever there are issues, and get back to me if this solves none of them.

If all that fails then hait could be that this:

1script.Disabled = true

Completely stops the script from running. Try adding a print at the end, i.e.:

01    Hit.Parent.Humanoid:TakeDamage(90)
02x:Destroy()
03game.Debris:AddItem(x,0.8)
04end
05wait(1)
06script.Disabled = false
07 
08print("Ran successfully")
09 
10end)end
11end)

If this doesn't print then your disabling the script stopped it from running the code as a whole.

If this is the case the use a debounce.

Otherwise

0
If you copied this script then stop developing BlackOrange3343 2676 — 7y
0
i didnt copy it ;-; izanagi456 4 — 7y
Ad

Answer this question