This is for a fireball thing, I'm trying to have it to detect what it touches, but it always just says Creator_Touch, even after it hits the part it doesn't say Part_Touch. Please, anything helps
function PartHit(Hit)
local CreatorPlayer = GetCreator()
if not Hit or not Hit.Parent or not CreatorPlayer or HitDelay or Part.Velocity.Magnitude < 8 then
return
end
local character = Hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid or humanoid.Health == 0 then
return
end
-- This is the part I can't get to work
if Hit.Parent == CreatorPlayer.Character then
print('Creator_Touch')
else
if Hit.Parent:FindFirstChild('Humanoid') and Hit.Parent ~= CreatorPlayer.Character then
print('Player_Touch')
elseif not Hit.Parent:FindFirstChild('Humanoid') then
print('Part_Touch')
Part:Destroy()
end
end
-- The end of it
local player = Players:GetPlayerFromCharacter(character)
if player and (CreatorPlayer == player or Functions.IsTeamMate(CreatorPlayer, player)) then
return
end
HitDelay = true
Functions.UntagHumanoid(humanoid)
Functions.TagHumanoid(humanoid, CreatorPlayer)
humanoid:TakeDamage(Damage.Value)
for i, v in pairs(character:GetChildren()) do
if v:IsA("BasePart") and v.Transparency < 1 then
local Fire = FireSpread:Clone()
Fire.Enabled = true
local ParticleScriptCopy = ParticleScript:Clone()
ParticleScriptCopy.Disabled = false
ParticleScriptCopy.Parent = Fire
Debris:AddItem(Fire, 3)
Fire.Parent = v
end
end
local PL = script.PointLight:Clone()
PL.Color = PLColor
PL.Parent = humanoid.Parent.Head
Debris:AddItem(PL, 3)
Part.Anchored = true
Part.Transparency = 0
for i, v in pairs(Part:GetChildren()) do
if v:IsA("ParticleEmitter") or v:IsA("Fire") or v:IsA("Smoke") or v:IsA("Sparkles") or v:IsA("Light") then
v.Enabled = false
end
end
Debris:AddItem(Part, 1.5)
end
Part.Touched:connect(PartHit)
