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

I need help with my script, only one tool goes away, and doesn't come back (More Inf In post) (?)

Asked by 2 years ago

Ello Developers!

I have a Issue, the Issue Is this script, basically, when the script Is enabled, I want all the tools on the player to go to a folder Inside of ReplicatedStorage, kinda like a tool debounce, and after a second, all weapons go back to Its owner, the problem for some reason Is:

  1. Only one tool goes away, which Is the tool you equipped to activate the ability
  2. The said weapon will also not come back

Script:

local NPC = script.Parent

if script.Enabled == true then
    local NPCWeaponsCheck = NPC:GetChildren()
    for _, Weapons in ipairs(NPCWeaponsCheck) do
        if Weapons:IsA("Tool") then
            Weapons.Parent = game:GetService("ReplicatedStorage").StorageForMoves
        end
    end
    local POW = NPC.Humanoid:WaitForChild("Animator"):LoadAnimation(NPC.Smash)
    POW:Play()
    local OriginalSpeed = Instance.new("NumberValue",NPC)
    game:GetService("Debris"):AddItem(OriginalSpeed,5)
    local OriginalJumpPower = Instance.new("NumberValue",NPC)
    game:GetService("Debris"):AddItem(OriginalJumpPower,5)
    OriginalSpeed.Value = NPC.Humanoid.WalkSpeed
    OriginalJumpPower.Value = NPC.Humanoid.JumpPower
    NPC.Humanoid.WalkSpeed = 0
    NPC.Humanoid.JumpPower = 120
    wait(0.20)
    local CanDamage = true
    script.SmashGround:Play()
    script.Flying:Play()
    NPC.Humanoid.Jump = true
    NPC.Humanoid.WalkSpeed = 50
    local Pound = game:GetService("ReplicatedStorage").Smash:Clone()
    game:GetService("Debris"):AddItem(Pound,5)
    Pound.Parent = game.Workspace
    Pound.Position = NPC.Torso.Position
    Pound.Position = Pound.Position + Vector3.new(0,-1,0)
    Pound.Size = Vector3.new(1,1,1)
    Pound.BrickColor = BrickColor.White()
    Pound.Material = Enum.Material.Plastic
    local TweenProperty = {
        Size = Pound.Size + Vector3.new(25,0.3,25),
        Transparency = 1
    }
    local Tweeninfo = TweenInfo.new(
        1,
        Enum.EasingStyle.Circular,
        Enum.EasingDirection.InOut,
        0,
        false,
        0
    )
    local Tween = game:GetService("TweenService"):Create(Pound,Tweeninfo,TweenProperty)
    Tween:Play()
    Pound.Touched:Connect(function(hit)
        local humanoid = hit.Parent:WaitForChild("Humanoid")
        if humanoid ~= NPC.Humanoid and CanDamage == true then
            humanoid:TakeDamage(30)
            CanDamage = false
            wait(.05)
            CanDamage = true
        end
    end)
    wait(1)
    game:GetService("Debris"):AddItem(Pound,0)
    NPC.Humanoid.WalkSpeed = OriginalSpeed.Value
    NPC.Humanoid.JumpPower = OriginalJumpPower.Value
    game:GetService("Debris"):AddItem(OriginalSpeed,0)
    game:GetService("Debris"):AddItem(OriginalJumpPower,0)
    local NPCWeaponsCheck2 = NPC:GetChildren()
    for _, Weapons2 in ipairs(NPCWeaponsCheck2) do
        if Weapons2:IsA("Tool") then
            Weapons2.Parent = NPC
        end
    end
end
1
Remove line 63 and change "NPCWeaponsCheck2" to "NPCWeaponsCheck." 9mze 193 — 2y
0
Thanks It works! Just It doesn't also removed and bring back the other weapons, but Ill try to work on It, imnotaguest1121 362 — 2y

Answer this question