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 7 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

local nuke = script.Parent
local pos = nuke.cFrame

while true do
    wait()
    nuke.Size = nuke.Size + Vector3.new(0.1, 0.1, 0.1)
    print(nuke.Size)
    if nuke.Size == 10, 10, 10 then
        nuke:remove()
    end
end

2 answers

Log in to vote
0
Answered by 7 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:

local nuke = script.Parent
local pos = nuke.cFrame

while true do
    wait()
    nuke.Size = nuke.Size + Vector3.new(0.1, 0.1, 0.1)
    print(nuke.Size)
    if nuke.Size == Vector3.new(10, 10, 10) then -- Notice the new Vector3.new() ?
        nuke:remove()
    end
end
Ad
Log in to vote
0
Answered by
tkcmdr 341 Moderation Voter
7 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:

local Nuke  = script.Parent;
local Position  = Nuke.CFrame;  -- I suggest removing this variable if you're not going to use it.

for size = 0, 10, .1 do
    -- Notice how size increments .1 each iteration and is applied on each axis
    Nuke.Size = Vector3.new(size, size, size);

    wait(.01);
end;

game: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