I have a ball that you go into and when you click this button its meant to clone it and place it at the cords but it doesn't someone please help me. it clones if I take out the clicked function but it just keeps multiplying which I don't want I only want it to multiply once when button is clicked reply as soon as possible please. I want it to clone the block but also the script that puts the player in ball which is in the ball part. I am not very good with scripts so if you could at least tell me what I did wrong and where to put things i might be able to fix it.
function onClicked()
while true do
model = game.Workspace.Ball.Ball:clone()
model.Parent = game.Workspace.new_ball
model.Position = Vector3.new(-50,5,-64)
print("cloned")
wait(10)
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)`
I put the script in the clickdetector which is in the button. The ball which I want to clone is in the same folder with the button. Thank you to anyone that helps.
I tweaked it a bit because I found script analysis and I removed the while true part but it still doesn't work
function onClicked()
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
game.Workspace.Ball.Ball:clone()
local Parent = game.Workspace.new_ball
local Position = Vector3.new(-50,5,-64)
print("cloned")
end

2 comments
tag me if my solution in the chat does not work (u can tag me in the comments)
@MarkoFANTASTINE1, @thecelestialcube, @2_MMZ I removed the while true bit and the end which went with that but it still don't work any ideas?