How can I make the ball spawn more than once

  1. What do you want to achieve? An orb shooting ability

  2. What is the issue? The script work perfectly at first, but once I try to use it for a second time I get an error saying The Parent property of waterBall is locked, current parent: NULL, new parent Workspace

  3. What solutions have you tried so far? I tried using the debris system but I kept getting the same error

here’s my script

-- variables
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character

local splash = RS.Splash:Clone()
local waterBall = RS.waterBall
local bv = Instance.new("BodyVelocity")
bv.P = math.huge
bv.Velocity = Vector3.new(0,2,0)
bv.MaxForce = Vector3.new(4000,4000,4000)

local bvClone = bv:Clone()

local target = mouse.Target
local qPressed = false

-- script

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	
	if input.KeyCode == Enum.KeyCode.Q then
		if mouse.Target == workspace.Terrain then
			
			qPressed = true
			
			game.Debris:AddItem(waterBall, 5)
			waterBall.Parent = workspace
			waterBall.Position = mouse.Hit.p - Vector3.new(0,0.5,0)
			bv.Parent = waterBall
			
			for count = 1,5 do
				wait(1)
				bv.Velocity = bv.Velocity/2
			end
		end
	end
end)

UIS.InputEnded:Connect(function(input, gameprocessed)
	if input.KeyCode == Enum.KeyCode.Q then
		qPressed = false
		
		bv:Destroy()
		
		local moveVelocity = Instance.new("BodyVelocity", waterBall)
		moveVelocity.Velocity = CFrame.new(waterBall.Position, mouse.Hit.Position).LookVector * 100
		
		waterBall.Touched:Connect(function(Touched)
			if Touched:isDescendantOf(character) then return end
			
			splash.Position = waterBall.Position
			waterBall:Destroy()
			splash.Parent = workspace
			
			if Touched.Parent:FindFirstChild("Humanoid") then
				Touched.Parent:FindFirstChild("Humanoid"):TakeDamage(15)
			end

			wait(1)

			for i = 1,300 do
				splash.ParticleEmitter.Rate -= 10
				wait()
			end

			splash:Destroy()
		end)
	end
end)

All help is appreciated <3

i think u need to clone ur waterball because at first it sets the original waterball to workspace so when it tries to do it again theres nothing in replicatedstorage named waterball

Still gives me that error, it’s really strange

To clone something multiple times it should be added in some sort of loop or event to trigger it.

What you have done is put :Clone() outside the event (UIS.InputBegan or UIS.InputEnded).
If you clone it in the Event then it will Clone the ball when it is Triggered.

Hope it helps, if not i may have understood your question wrong.

Using Debris:AddItem() or calling :Destroy() on any instance will lock it’s parent and you won’t be able to re-parent it back, instead you should be either reparenting the ball to nil (which will allow you to put it back in it’s old place) or do what @DFROBUXX said