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

What is wrong with ice shard?(the debounce)

Asked by 7 years ago
player = game.Players.LocalPlayer
mouse = player:GetMouse()
char = player.Character
enabled = true -- whole script
iceS = true -- IceShard
isActive = false
ibActive = false
iceB = true --iceBlast
v3 = Vector3

function InstantiateBodyVelocity(object)
    local bv = Instance.new("BodyVelocity", object)
    bv.maxForce = v3.new(1, 1, 1) * math.huge
    return bv
end

local function iceShardCreate()
    x = Instance.new("Part", game.Workspace)
    x.BrickColor = BrickColor.new("Pastel blue-green")
    x.Size = v3.new(2,2,2)  
    x.CFrame = char.Torso.CFrame *CFrame.new(0,0,-5)

    InstantiateBodyVelocity(x)
    isActive = true

    mesh = Instance.new("FileMesh", x)
    mesh.MeshId = "http://www.roblox.com/Asset/?id=9756362"
    print('Shard was created with bv')
    game.Debris:AddItem(x,4)
    isActive = false

    touched = false
    x.Touched:connect(function(hit)
        if hit.Parent:findFirstChild("Humanoid") and hit.Parent.Name ~= player.Name and touched == false then
            touched = true
            x:Remove()
            hit.Parent.Humanoid:TakeDamage(20)
            print("Shard did damage")
            touched = false
        end 
    end)
end 

The function to create the ice shard is above. ^^^^^

game:GetService("UserInputService").InputBegan:connect(function(input, gameProcessed)
    if input.KeyCode == Enum.KeyCode.Z and iceS == true and ibActive ~= true then
        --Ice Shard
        iceS = false
        game:GetService("Chat"):Chat(char.Head, "Ice Shard!", "Blue")
        iceShardCreate()
        print("Shard Created")
        wait(5) -- Ice Shard Reload time
        iceS = true
    end

These are some parts of my code. I have another attack named ice blast, and ice shard does not fire while "isB" is active. The problem after the second time I press the key "z" the body velocity is not activated. Currently, the shard is supposed to float. What am I doing wrong?

Answer this question