01 | local Clickd = script.Parent.ClickDetector |
02 | local Button = script.Parent |
03 | local RS = game:GetService( "ReplicatedStorage" ) |
04 | local EndFolder = RS:WaitForChild( "End" ) |
05 | local Pillar = EndFolder.Pillar |
06 | local Radius = 100 |
07 | local X = math.random( 0 ,Radius) |
08 | local Y = 0 |
09 | local Z = math.random( 0 ,Radius) |
10 |
11 |
12 | Clickd.MouseClick:Connect( function () |
13 | local ClonedPillar = Pillar:Clone() |
14 | ClonedPillar.Parent = workspace |
15 | ClonedPillar.Position = Vector 3. new(X,Y,Z) |
My cloned object is not spawning where I want it to, I've tried this with many other scripts and it doesn't work, one with an instance, the "Explosion" instance spawns at the middle of the baseplate. While the current script here spawns at one position, nothing else
Hi! Your code is choosing a number between 0 and 100 for once. To fix this, you simply can do a loop for the values X and Z. Heres a possible result:
01 | local Clicked = script.Parent.ClickDetector |
02 | local Button = script.Parent |
03 | local RS = game:GetService( "ReplicatedStorage" ) |
04 | local EndFolder = RS:WaitForChild( "End" ) |
05 | local Pillar = EndFolder.Pillar |
06 | local Radius = 100 |
07 | local X -- Nill value. |
08 | local Y = 0 |
09 | local Z -- Nill value. |
10 |
11 | Clicked.MouseClick:Connect( function () |
12 | print ( "work" ) |
13 | local ClonedPillar = Pillar:Clone() |
14 | ClonedPillar.Parent = workspace |
15 | ClonedPillar.CFrame = CFrame.new(X,Y,Z) |
It'll simply just generate a number every 0.03 seconds and if you click on the part, you can see it randomly generates to the given coordinates! If it doesn't work, then you can ask why it doesn't and what the error is. Have a good day!