local position = Vector3.new(math.random(8, 89), 7.5, math.random(-99,0))
local cf = CFrame.new(position)
local coinclone = game:GetService("ServerStorage").Coin:Clone()
game.Players.PlayerAdded:Connect(function()
local coins = {}
for i = 1, 10 do
local coincc = coinclone:Clone()
coincc.Parent = workspace
coincc:PivotTo(cf)
coins[i] = coincc
coin.Position = Vector3.new(math.random(8, 89), 7.5, math.random(-99,0))
end
while true do
task.wait(.01)
for _, coin in ipairs(coins) do
coin:PivotTo(coin:GetPivot() * CFrame.Angles(0,.1,0))
end
end
end)
change coin in coin.Position to coincc but keep it at its original place, which is inside of the first for loop where the coins are originally created.
local position = Vector3.new(math.random(8, 89), 7.5, math.random(-99,0))
local cf = CFrame.new(position)
local coinclone = game:GetService("ServerStorage").Coin:Clone()
game.Players.PlayerAdded:Connect(function()
local coins = {}
for i = 1, 10 do
local coincc = coinclone:Clone()
coincc.Parent = workspace
coincc:PivotTo(cf)
coins[i] = coincc
coincc.Position = Vector3.new(math.random(8, 89), 7.5, math.random(-99,0))
end
while true do
task.wait(.01)
for _, coin in ipairs(coins) do
coin:PivotTo(coin:GetPivot() * CFrame.Angles(0,.1,0))
end
end
end)
```sorry, my screenshot tool isn't working.
@EgizianoEG told me that coincc is a model, which explains the error. To fix it, you can either take a part inside the model, and set the position of that, or you do coincc:MoveTo(position)
local IPosition = Vector3.new(math.random(8, 89), 7.5, math.random(-99,0))
local InitialCFrame = CFrame.new(IPosition)
local CoinCloned = game:GetService("ServerStorage").Coin:Clone()
game.Players.PlayerAdded:Connect(function()
local coins = {}
for i = 1, 10 do
local coincc = CoinCloned:Clone()
coincc.Parent = workspace
coincc:PivotTo(InitialCFrame)
coins[i] = coincc
end
while true do
task.wait(.01)
for _, coin: Model in ipairs(coins) do
local PositionCFrame = CFrame.new(Vector3.new(math.random(8, 89), 7.5, math.random(-99,0)))
coin:PivotTo(coin:GetPivot() * CFrame.Angles(0,.1,0))
coin:PivotTo(PositionCFrame)
end
end
end)
Your issue was that you’re passing a Vector3 to the PivotTo method without converting it to a CFrame
You’d need to move those lines to the first for loop and delete the existing PivotTo line in that loop.
for i = 1, 10 do
local PositionCFrame = CFrame.new(Vector3.new(math.random(8, 89), 7.5, math.random(-99,0)))
local coincc = CoinCloned:Clone()
coincc.Parent = workspace
coincc:PivotTo(PositionCFrame)
coins[i] = coincc
end
Also, no need for the first two lines in the script…
local CoinCloned = game:GetService("ServerStorage").Coin:Clone()
game.Players.PlayerAdded:Connect(function()
local coins = {}
for i = 1, 10 do
local PositionCFrame = CFrame.new(Vector3.new(math.random(8, 89), 7.5, math.random(-99,0)))
local coincc = CoinCloned:Clone()
coincc.Parent = workspace
coins[i] = coincc
end
while true do
task.wait(.01)
for _, coin: Model in ipairs(coins) do
local PositionCFrame = CFrame.new(Vector3.new(math.random(8, 89), 7.5, math.random(-99,0)))
coin:PivotTo(coin:GetPivot() * CFrame.Angles(0,.1,0))
coin:PivotTo(PositionCFrame)
end
end
end)
It should not?
The for loop is generating a random CFrame every iteration, maybe try to print every CFrame generated to check if they are the same or something else happening…
@ZipMist, I just noticed that the PivotTo line was not included in the loop.
local CoinCloned = game:GetService("ServerStorage").Coin:Clone()
game.Players.PlayerAdded:Connect(function()
local coins = {}
for i = 1, 10 do
local PositionCFrame = CFrame.new(Vector3.new(math.random(8, 89), 7.5, math.random(-99,0)))
local coincc = CoinCloned:Clone()
coincc:PivotTo(PositionCFrame) -- your missed line...
coincc.Parent = workspace
coins[i] = coincc
end
while true do
task.wait(.01)
for _, coin: Model in ipairs(coins) do
coin:PivotTo(coin:GetPivot() * CFrame.Angles(0,.1,0))
end
end
end)