Can anyone please tell me how to know the size of a ball through a script? I’ve been trying for more than 3 hours but I can’t find how
while true do
local clonedpart = game.Workspace.Planets:WaitForChild("ClonedPlanet")
clonedpart:GetPropertyChangedSignal("Size"):Connect(function ()
if clonedpart.Size.X >= 1800 then
clonedpart.Material = "Neon"
local randomcolor = math.random(1,3)
if randomcolor == 3 then
clonedpart.Color = Color3.new(1, 1, 0)
end
if randomcolor == 3 then
clonedpart.Color = Color3.new(1, 1, 1)
end
if randomcolor == 3 then
clonedpart.Color = Color3.new(0, 0, 0)
end
end
end)
end
All that you need to do is part.Size. This gives you the size of the part, or ball in this case. As for your code. If the number is three then it will run all three if statements and end up being Color3.new(0,0,0)
Also, why is it in a While true do loop? There is nothing being looped, so there is no reason to loop it at all. With the loop, the script should not work at all and the execution time will run out.
If this is running on a server script, then you do not need the :WaitForChild() either.
One last thing… What exactly is it that you want to achieve?
The script is being executed as a normal script, no local or module. The while true do loop makes an infinite planet spawn system and I’m trying to calculate the size of a planet to make it a sun (neon.)
I think you meant math.min because if you use max then when one side is smaller, the sphere will be smaller, and not reach the full size. Spheres take on a radius of half of the smallest size in roblox, not the largest.