Your error is how your storing the positions
local Coins = game.ServerStorage.Coins
local CoinsNames = {
"BronzeCoin",
"GoldCoin",
"SilverCoin",
}
local Positions = {
Vector3.new(-154.1, 1.1, 86.9),
Vector3.new(-170.1, 1.1, 61.9),
Vector3.new(-132.1, 1.1, 63.9),
Vector3.new(-144.1, 1.1, 46.9),
Vector3.new(-172.1, 1.1, 36.9),
}
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:
Coins.Position = 54.33
While you actually wanted
Coints.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:
local Coins = game.ServerStorage.Coins
local CoinsNames = {
"BronzeCoin",
"GoldCoin",
"SilverCoin",
}
local Positions = {
-154.1, 1.1, 86.9,
-170.1, 1.1, 61.9,
-132.1, 1.1, 63.9,
-144.1, 1.1, 46.9,
-172.1, 1.1, 36.9,
}
while true do
for i,v in pairs(Coins.FolderCoins:GetChildren()do
wait(0.5)
if Coins.Name == CoinsName[math.random(1, #CoinsNames)]then
Coins.Position = Vector3.new(Positions[math.random(1, #CoinsNames)])
x = Coins:Clone()
x.Parent = game.Workspace
end
end
end
end
And take a look at my:
local Coins = game.ServerStorage.Coins
local CoinsNames = {
"BronzeCoin",
"GoldCoin",
"SilverCoin",
}
local Positions = {
Vector3.new(-154.1, 1.1, 86.9),
Vector3.new(-170.1, 1.1, 61.9),
Vector3.new(-132.1, 1.1, 63.9),
Vector3.new(-144.1, 1.1, 46.9),
Vector3.new(-172.1, 1.1, 36.9),
}
while true do
for i,v in pairs(Coins.FolderCoins:GetChildren()do
if v.Name == CoinsName[math.random(1, #CoinsNames)] then
wait(0.5)
local coin = v:Clone()
coin.Parent = workspace
coin.Position = Vector3.new(Positions[math.random(1, #CoinsNames)])
end
end
end
If this help please vote up and as accepted, if it doesn't let me know and I'll help more. :)
2 comments
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.
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.