-
What do you want to achieve? An orb shooting ability
-
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
-
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