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

Why isn't the charging function working?

Asked by
Txngo 5
10 years ago

When the player pressees shift its supposed to make their Powers value go up.

local ExoSkeleton = create{"Model", Parent = character, Name = "Skeleton"}
for i,v in pairs(character:GetChildren()) do
    print("checking for parts")
    if v:IsA('Part') and v.Name ~= "Head" then
        create{"SelectionBox", Parent = ExoSkeleton, Name = "Outline", Transparency = 1, Adornee = v}
    end
end

local power = create{"NumberValue", Parent = player, Value = 0, Name = "Power"}

while charging == false do
    wait()
    Exo = ExoSkeleton:GetChildren()
    for i,v in pairs(Exo) do
        if v:IsA("SelectionBox") then
            if power.Value == 100 then
                v.Transparency = 0
            else
                x =  math.random(70,100)
                v.Transparency = x*0.01
            end
        end
    end         
end


while wait() do
mouse.KeyDown:connect(function(key)--i was in the middl of making the keydown function that checks what key it is and how long its being pressed
if string.byte(key) == 017 or string.byte(key) == 016 then
    charging = true
     power.Value = power.Value +1
    while wait() do
        Exo = ExoSkeleton:GetChildren()
        for i,v in pairs(Exo) do
            if v:IsA('SelectionBox') then
                for i = 1,100 do
                    wait(0.5)
                    v.Transparency = i*0.01
                end

            end
        end
    end
end
end)
end
while wait() do
mouse.KeyUp:connect(function(key)
if string.byte(key) == 017 or string.byte(key) == 016 then
    charging = false
end 
end)
end

Answer this question