Error with Not a valid member whilst using :Clone

Issue
So what’s happening is I cant actually get my script to function correctly. I’m making a basic spell for my game and this requires me to clone an object. Yet for some reason after I’ve cast the spell once it doesn’t fire.

Yes, I’ve made sure that nothing is deleting or destroying it. The only thing which I can think of which would cause this error would be the line which sends the energy ball to the workspace.

Attempts to fix it
I’ve tried indenting anything which would cause this error and tried disabling some other scripts. Yet nothing seems to work.

Code

local Tool = script.Parent.Parent.Parent
local play = Tool.Parent
local char = play.Character
local hum = char.Humanoid 
local root = char.HumanoidRootPart
local cooldown = false
local CDTime = 4
local Damage = 25

script.Parent.Parent.RemoteEvent.OnServerEvent:Connect(function(player, Mouse)
	if cooldown then return end
	local LightningPulse = script.LightningPulse:Clone()
	
	local Character = game.Workspace[player.Name]
	
	LightningPulse.CFrame = CFrame.new(Character.Head.CFrame.p, Mouse.p) + CFrame.new(Character.Head.CFrame.p, Mouse.p).lookVector * 3
		
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.Velocity = LightningPulse.CFrame.lookVector * 125
	BodyVelocity.MaxForce = Vector3.new(1e6,1e6,1e6)
	BodyVelocity.Parent = LightningPulse
	
	LightningPulse.Parent = game.Workspace
	LightningPulse.Script.Disabled = false
	LightningPulse.Damage.Disabled = false
	LightningPulse.Player.Value = player.Name
	
	cooldown = true
	wait(CDTime)
	cooldown = false
end)

I’m still working on some aspects of it so it may not be the best. Is there anyway I can fix it. I have no idea what’s going wrong.

Error

image

2 Likes

script.LightningPulse is your error, the output is indicating that LightningPulse does not exist as a child of the script. Are you sure the object is inside the script?

Yeah, whenever I fire the spell it works perfectly the first time and once I fire it once more it says it doesn’t exist. I couldn’t find it in the explorer either.

I found a solution, it for some reason wasn’t cloning it because of it being a descendant of the tool. So I created a folder in the lighting and just cloned it from there.