I’m trying to make a script that clones a model but it gives me an error that says, “position is not a valid member of model”. How do I change the position of the clone?
local rc = game:GetService("ReplicatedStorage"):WaitForChild("Coin")
local x = math.random(-466.36, 446.175)
local z = math.random(-485.09, 465.36)
while true do
rcc = rc:Clone()
rcc.Name = "CoinClone"
rcc.Parent = game.Workspace
rcc.Position = Vector3.new(x, .5, z)
wait(1)
end
It’s only changing once because the x and z are not within the loop!
You're code would be:
local rc = game:GetService("ReplicatedStorage"):WaitForChild("Coin")
while true do
local x = math.random(-466.36, 446.175)
local z = math.random(-485.09, 465.36)
rcc = rc:Clone()
rcc.Name = "CoinClone"
rcc.Parent = game.Workspace
rcc.Position = Vector3.new(x, .5, z)
wait(1)
end
which means that rc is a model. You should use :PivotTo(CFrame.new(x, .5, z)) instead.
Also, adding decimal places on the parameters of math.random won’t do anything since math.random returns an integer.
Also, its better to set the properties of an instance before parenting.
local rc = game:GetService("ReplicatedStorage"):WaitForChild("Coin")
while true do
local x = math.random(-466, 446)
local z = math.random(-485, 465)
local rcc = rc:Clone()
rcc.Name = "CoinClone"
rcc:PivotTo(CFrame.new(x, .5, z))
rcc.Parent = workspace
wait(1)
end
You are trying to make the MODEL move, And position is not found in the properties of model. So if u are trying to make it move, You will need to weld the other stuff in it to the Primary Part (Primary part of your choice), Then clone the model and make the PRIMARY PART move, That will fix it.