I want to make my script make more balls in the rough area of the ball
nothing is happening
I have tried moving the “while true do” things around
Is it something to do with how I am trying to do the position?
also, the code is in a script under a sphere part.
-- local parent = script.Parent
local color = script.Parent.Color
local mat = script.Parent.Material
local shape = script.Parent.Shape
local posX = script.Parent.Position.X
local posY = script.Parent.Position.Y
local posZ = script.Parent.Position.Z
while true do
local posX2 = posX + math.random(-3,3)
local posY2 = posY + math.random(-3,3)
local posZ2 = posZ + math.random(-3,3)
local rock = Instance.new("Part")
rock.Name = "rock"
rock.Shape = shape
rock.Material = mat
rock.Color = color
rock.Position.X = posX2
rock.Position.Y = posY2
rock.Position.Z = posZ2
wait(5)
end
Firstly these variables will store the original position of the part instead of updating, so if that’s something you don’t want you need to move those variables inside the while loop.
Secondl,y the rock has been created but it is not parented to workspace, so you can’t see it.
Thirdly, you can’t directly assign the X,Y,Z coordinates like this.
Do this instead:
rock.Position = Vector3.new(posX2,posY2,posZ2)
By the way, ensure you use “task.wait” as it is the new version of wait.
how do I parent it properly? i should know how do do this since I’ve made a falling platform script that duplicates an object but I’ve managed to forget
while true do
local posX = script.Parent.Position.X
local posY = script.Parent.Position.Y
local posZ = script.Parent.Position.Z
local posX2 = posX + math.random(-3,3)
local posY2 = posY + math.random(-3,3)
local posZ2 = posZ + math.random(-3,3)
local rock = Instance.new("Part")
rock.Name = "rock"
rock.Shape = shape
rock.Material = mat
rock.Color = color
rock.Position = Vector3.new(posX2, posY2, posZ2)
rock.Parent = workspace
task.wait(5)
end