I'vebeen trying to create a fireball that damages other players when they come into contact with it. The problem is, that for some reason the damage script doesn't work, and I keep getting the error "Touched isn't a valid member of local script." I've tried moving around where to clone the script in the fireball's code but it just doesn't want to work for some reason. It would really help if someone could tell me how to fix this. Fireball Code:
local variable cooldown = 1
function shoot()
if cooldown == 1 then
print("Works")
cooldown = 0
local fireball = Instance.new("Part") --Creates a new Part Called Fireball
fireball.TopSurface = "Smooth"
fireball.BottomSurface = "Smooth"
fireball.BrickColor = BrickColor.new("Really red")
fireball.Transparency = 0.3
fireball.Size = Vector3.new(2, 2, 2)
fireball.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame *CFrame.new(0,0,-5) --Where the Fireball Starts
fireball.Parent = game.Workspace
fireball.Anchored = true --Anchors Fireball
fireball.CanCollide = false
local damage = script.Damage:clone() --Clones the damage script
damage.Parent = fireball
damage.Disabled = false --Enables the damage script
local mesh = Instance.new("SpecialMesh", fireball) --Adds a mesh to the Fireball
mesh.MeshType = "Sphere" --Makes the mesh a sphere
local fire = Instance.new("Fire", fireball) --Adds fire to the fireball
fire.Heat = 8
fire.Size = 20
local bv = Instance.new("BodyVelocity") --creates velocity for the fireball
bv.maxForce = Vector3.new(math.huge,math.huge,math.huge) --MaxForce is so high almost as to be unlimited
bv.velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector*80
for i = 1,13 do
fireball.Mesh.Scale = fireball.Mesh.Scale +Vector3.new(0.5,0.5,0.5) --Makes the fireball grow
wait()
end
bv.Parent = fireball --Adds the velocity to the fireball
fireball.Anchored = false
wait(3)
cooldown = 1
fireball:Destroy()
end
end
script.Parent.Activated:connect(shoot)
And here's the damage code:
local enabled = false
function Damage(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h and not enabled then
enabled = true
for i = 1,20 do
h.Health = h.Health - 3
wait(1/15)
end
end
enabled = false
end
script.Parent.Touched:connect(Damage)

4 comments
i think Touched doesnt work with CanCollide off. try turning it on then trying it and get back to me
Mind showing us what the tool looks like in the Explorer menu?
Bubbaman, touched does work with CanCollide off :P
Try changing the local script inside the fireball to a regular script.