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

Why doesnt this script work?

Asked by 9 years ago

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

I was trying to make it clone the coin that was picked and cloned to the workspace and it didnt work...

01--[[
02script.Parent.BrickColor = BrickColor.new(colors[math.random(1, #colors)]
03Scripted by Dreamingrocky/UltraUnitMode.   
04--]]
05local Coins = game.ServerStorage.Coins
06local CoinsNames = {
07"BronzeCoin",
08"GoldCoin",
09"SilverCoin",
10}
11 
12local Positions = {
13-154.1, 1.1, 86.9,
14-170.1, 1.1, 61.9,
15-132.1, 1.1, 63.9,
View all 32 lines...

2 answers

Log in to vote
1
Answered by
Kurieita 125
9 years ago

Your error is how your storing the positions

01--[[
02script.Parent.BrickColor = BrickColor.new(colors[math.random(1, #colors)]
03Scripted by Dreamingrocky/UltraUnitMode.   
04--]]
05local Coins = game.ServerStorage.Coins
06local CoinsNames = {
07"BronzeCoin",
08"GoldCoin",
09"SilverCoin",
10}
11 
12local Positions = {
13Vector3.new(-154.1, 1.1, 86.9),
14Vector3.new(-170.1, 1.1, 61.9),
15Vector3.new(-132.1, 1.1, 63.9),
View all 32 lines...

Your problem was that the interpreter thought that you were storing a double type number, meaning a number with a decimal. While in reality you wanted the interpreter to return Vector3 values.

To sum it up

Lua thought this:

1Coins.Position = 54.33

While you actually wanted

1Coints.Position = Vector3.new(0, 0, 0)

Also, I noticed your code have some syntax errors plus other interpreted errors. Take a look at your code:

01--[[
02script.Parent.BrickColor = BrickColor.new(colors[math.random(1, #colors)]
03Scripted by Dreamingrocky/UltraUnitMode.   
04--]]
05local Coins = game.ServerStorage.Coins
06local CoinsNames = {
07"BronzeCoin",
08"GoldCoin",
09"SilverCoin",
10}
11 
12local Positions = {
13-154.1, 1.1, 86.9,
14-170.1, 1.1, 61.9,
15-132.1, 1.1, 63.9,
View all 32 lines...

And take a look at my:

01--[[
02script.Parent.BrickColor = BrickColor.new(colors[math.random(1, #colors)]
03Scripted by Dreamingrocky/UltraUnitMode.   
04--]]
05local Coins = game.ServerStorage.Coins
06local CoinsNames = {
07"BronzeCoin",
08"GoldCoin",
09"SilverCoin",
10}
11 
12local Positions = {
13Vector3.new(-154.1, 1.1, 86.9),
14Vector3.new(-170.1, 1.1, 61.9),
15Vector3.new(-132.1, 1.1, 63.9),
View all 30 lines...

If this help please vote up and as accepted, if it doesn't let me know and I'll help more. :)

0
Kurieita I have copied the script that you have made and saw the script and i went over it. But i doesnt work, also the output doesnt have any errors. UltraUnitMode 419 — 9y
0
Try debugging, meaning put print("A"), print("B") and so on around the whole script, and see which one prints and which one doesn't. Let me know which line and I be more than happy to take a look. Kurieita 125 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

Another error. Change this:

1for i,v in pairs(Coins.FolderCoins:GetChildren()do

To:

1for i,v in pairs(Coins.FolderCoins:GetChildren()) do
0
Yes, that was one of the syntax error. I thought I posted it, guess not. Kurieita 125 — 9y

Answer this question