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

Why is this not working?

Asked by
Sineo 5
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I am trying to make a script that will spawn an object randomly throughout a map , the script isn't spawning the object at all , and there is no syntax errors

H=game.Lighting:FindFirstChild("SpawnScript").Parent.Instanceclone()

if 5>1  then do
    game.Lighting:FindFirstChild("FireDragonSlayerBall").Parent.Instanceclone(1)
    H.Properties.Position = 2307.104, 148.5, -73.582        
    wait(3)

end 
end
print ("5>1") 
1
" there is no syntax errors" I see three errors right off the bat. Instanceclone() is not even a valid function of an object, even if it was then it would be called with a ":" not a ".". Second, do is not necessary, and is quite redundant when you have the "then" statement in there. It's not even part of an if then statement. Also, there is not arguments required for the Clone function. M39a9am3R 3210 — 8y
0
Please review the wiki, and check out some sources to find out how to script in RBX.Lua. M39a9am3R 3210 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

Try this:

if 5>1 then
    game.Lighting["FireDragonSlayerBall"].Parent.Instance:clone()
    H.Properties.Position = Vector3.new(2307.104, 148.5, -73.582)        
    wait(3)
    end 
end
print ("5>1")

H is also undefined, so I am not sure if you have that set already.

When cloning something, you just use Object:clone() If you are instancing something, just do local variable = Instance.new("Object") then do whatever you want with it.

This code looks incomplete so I tried my best to answer.

EDIT: You also don't put a do statement after then, that is only used in certain loops.

EDIT2: You also need to put a Vector3 function around the position, so that the game knows where to put the object. You also need to do something when cloning the object. You need to set a variable, then decide what to do with that variable.

Ad
Log in to vote
0
Answered by 8 years ago

Okay, first of all. Why do you even check if 5 is greater than 1? There is no need for even checking, because it will always be.

Your code:

if 5>1  then do
    game.Lighting:FindFirstChild("FireDragonSlayerBall").Parent.Instanceclone(1)
    H.Properties.Position = 2307.104, 148.5, -73.582        
    wait(3)

end 
end
print ("5>1") 

Should be:

if 5>1  then
    local H = game.Lighting:FindFirstChild("FireDragonSlayerBall"):clone()
    H.Position = Vector3.new(2307.104, 148.5, -73.582)
    wait(3)
end
print ("5>1") 

Answer this question