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

How is this INSTANTLY skipping the ENTIRE function????

Asked by 3 years ago

I dont get it. As soon as the Shoot() function starts, it INSTANTLY SKIPS THE ENTIRE WAIT! PLEASE! SOMEONE HELP! THIS IS DRIVING ME INSANE! Here is the script that is getting on my nerves....

local AllowInput = false
if game.Players:GetPlayerFromCharacter(script.Parent) then
    AllowInput = true
    spawn(function()
        while wait() do
            if script:WaitForChild('ref').Value.Value ~= script:WaitForChild('ref'):WaitForChild('ref').Value.Name then
                script:Destroy()
            end
        end
    end)
end
function Shoot(mousepos)
    local object =  script.Libraries.Object.LazerExample:Clone()
    object.Parent = script.Parent
    object.Position = mousepos[1] + Vector3.new(0,1024,0)
    for i = 0,1,-0.01 do
        object.Transparency = i
        wait(1000000000000000000000000000000000000)
    end
    print('done')
    if object.Parent and object then
        object:Destroy()
    end
end
script.Input.Value.Event:Connect(function(Action)
    if not AllowInput then return end
    if Action[1] == '1' then
        script:WaitForChild('ref'):WaitForChild('ref'):WaitForChild('ref').Value.Value = true
        Shoot(Action[2])
        script:WaitForChild('ref'):WaitForChild('ref'):WaitForChild('ref').Value.Value = false

        --[[    
        script.Parent.Humanoid.WalkSpeed = 0.5
        script.Parent.Humanoid.JumpPower = 0
        script.Parent.GunnerAnimate.Disabled = true
        Shoot(Action[2])
        script.Parent.GunnerAnimate.Disabled = false
        script.Parent.Humanoid.WalkSpeed = 16
        script.Parent.Humanoid.JumpPower = 50
        script:WaitForChild('ref'):WaitForChild('ref'):WaitForChild('ref').Value.Value = false
        ]]
    end
end)
0
I see, the problem is that the wait() is inside the function, you will probably have to put it outside the function, I hope my answer was helpful shieldmr3 2 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

the wait(1000000000000000000000000000000000000) is unnecessary, the function will end and stop on its own, you dont need to extend it indefinitely. But, if you do want the wait anyway, try changing it to math.huge, math.huge is infinite

0
i added wait( however long this is) bc i was seeing if it would delay at all rookiecookie153 53 — 3y
0
i added wait( however long this is) bc i was seeing if it would delay at all rookiecookie153 53 — 3y
0
i added wait( however long this is) bc i was seeing if it would delay at all rookiecookie153 53 — 3y
Ad
Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

line 16

for i = 0,1,-0.01 do

When you are adding from 0 to 1 you need to add 0.01, not substract -0.01. This means change it to this

for i = 0,1,0.01 do

I also don't want to say something but why do you have wait(1000000000000000000000000000000000000)? It will stop the loop for one undecillion seconds, this means one loop part will end in 12/04/292277026596 3:30pm at UTC, uh oh, that's how many years?! i think it's not exactly what you wanted to implement, notice, your loop will run ~100 times so it's ~100 undecillions seconds for one loop!

0
sorry i forgot to remove the wait, i was trying to see if it would delay. Also, i forgot to switch the 0 to 1 on the for loop. rookiecookie153 53 — 3y
0
so the loop looks like this; for i = 1, 0, -0.01 and it is still causing problems? imKirda 4491 — 3y

Answer this question