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)
Am not sure whats happening exactly but, if you want to detect the ball hiting another player/part I would go about do this;
function PartHit(Hit) local CreatorPlayer = GetCreator() --am guessing this gets the owner's character local players = game.Players:GetChildren() local done = false for i=1,#players do if Hit.Parent == players[i].Character then if player[i].Character ~= CreatorPlayer then print("Player Touch") else print("Creator Touch") end done = true end end if done == false then print("Part Touched") end
i like to refer to game.Players but that is just my preference. I am sure there are better ways of doing this but this is just one way. Hope that helped :)
also, in the future, giving more detail about what your making will help us help you sense we may be able to figure out more clever solutions.