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

Need Help for a Nuke Script? [Somewhat beginner/Intermediate]

Asked by 8 years ago

So I'm somewhat beginner/intermediate in lua and I'm trying to test my self and trying to make a nuke. What I'm trying to do here is after the size reaches 10, 10, 10 then it would just disappear using destroy(). The problem is I can't figure out how to do this. Here is my

01local nuke = script.Parent
02local pos = nuke.cFrame
03 
04while true do
05    wait()
06    nuke.Size = nuke.Size + Vector3.new(0.1, 0.1, 0.1)
07    print(nuke.Size)
08    if nuke.Size == 10, 10, 10 then
09        nuke:remove()
10    end
11end

2 answers

Log in to vote
0
Answered by 8 years ago

I can see a problem right off the bat, you're not using Vector3 for the size. That seems to be your only problem, though. To check the size, or set it you must use Vector3.new()...

So here is what your script should look like:

01local nuke = script.Parent
02local pos = nuke.cFrame
03 
04while true do
05    wait()
06    nuke.Size = nuke.Size + Vector3.new(0.1, 0.1, 0.1)
07    print(nuke.Size)
08    if nuke.Size == Vector3.new(10, 10, 10) then -- Notice the new Vector3.new() ?
09        nuke:remove()
10    end
11end
Ad
Log in to vote
0
Answered by
tkcmdr 341 Moderation Voter
8 years ago

Hello xXCyberProXx,

In your case, it may be better to use a for loop and add schedule your nuke to be deleted at a later time. Consider the following:

01local Nuke  = script.Parent;
02local Position  = Nuke.CFrame;  -- I suggest removing this variable if you're not going to use it.
03 
04for size = 0, 10, .1 do
05    -- Notice how size increments .1 each iteration and is applied on each axis
06    Nuke.Size = Vector3.new(size, size, size);
07 
08    wait(.01);
09end;
10 
11game:GetService("Debris"):AddItem(Nuke, 1);

For more info on for loops and Debris, visit these Wiki pages:

http://wiki.roblox.com/index.php?title=Loops#For

http://wiki.roblox.com/index.php?title=API:Class/Debris#For

Have a nice day, xXCyberProXx, and best of luck with your project!

Warm regards,

tkcmdr

Answer this question