Issue with code working on newly spawned balls

You can write your topic however you want, but you need to answer these questions:

Hi! I’m trying to make a GUI that has two buttons that can increase, and decrease the size of all of the parts named “Ball”. The ball needs to change sizes in order to progress through the map.

I want to fix my scripts, so it doesn’t matter which ball is there, and it still works.

I have most of it done, but the way the game is, the starting ball often falls in the void. After the ball falls in the void, the GUI to change the ball’s size no longer works. (I have a button that respawns the ball.)

I’ve been looking for solutions for a little while, but I haven’t found anything. I’ve tried setting it so all the balls will go into a folder, but that did nothing. I have tried using :WaitForChild (and things like it) but well, those didn’t work either.

Here is me showing it works :

This is the new ball :

This is my code for the gui that decreases the size, (you can see where I attempted to put the balls in a folder, and when I tried to use :FindFirstChild etc)
image

I’ll describe it a little better. I have two GUI buttons, that when you click them, it increases, or decreases the starter ball’s size. (In order to get into smaller gaps), That part is working, but I can’t get it to change the size of the new balls that spawn. (The starter one tends to fall in the void)

Thanks!

If the ball respawns, you can try this:

function decrease()
	local ball = workspace.Balls:FindFirstChild("Ball")
	if ball then
		-- resize
	end
end

Basically it pre-checks to see if the ball exists or not.

Thanks! This works a lot better then what I was trying to do!

1 Like