So for some reason my second if statement isn’t firing for some reason. I’m not sure why and I tried multiple ways, but it doesn’t work for some reason. (It’s a fireball by the way. If it touches the sender then it ends. But, when it touches a wall for example it doesn’t activate).
Script:
Clone.Touched:Connect(function(Hit)
local Humanoid = Player.Character:WaitForChild("Humanoid")
if Creator then
return
end
if Humanoid or not Humanoid then
Humanoid.Health -= (FireballDamage)
Clone.Anchored = true
Tween:Play()
wait(2)
Clone:Destroy()
end
end)
end)
You could just simply play the Tween outside the conditional check?
local DB = false
Clone.Touched:Connect(function(Hit)
Tween:Play()
local Humanoid = Player.Character:WaitForChild("Humanoid")
if Creator or DB then
return
end
DB = true
if Humanoid or not Humanoid then
Humanoid.Health -= (FireballDamage)
Clone.Anchored = true
wait(2)
Clone:Destroy()
end
end)
end)
Regarding the main topic, we firstly have to get some issues addressed here. In the second line, you seem to reference Player, but did you ever make Player a variable in the first place? Because if you didn’t, of course, it’d return nil and give an error. Which also brings us to another question: was there any errors? Errors are crucial to finding the issue within the code, thus without them, it will be harder to solve this. Secondly, I personally recommend you to replace Humanoid.Health -= (Damage) with a built-in function for this (Humanoid:TakeDamage(Damage), although you should note this won’t bypass ForceFields.
That’s a bit of what I could notice, hope this helps.