I'm working on a game that basically allows you to have superpowers, and the first power I'm creating is a fireball launcher. Whenever you click somewhere, a fireball mesh is sent to the location through a tween (the easingstyle is Enum.EasingStyle.Linear so it's going straight to the point). The fireball is supposed to hurt things it touches if it has a Humanoid (to hurt players/NPCs). However, this fireball is not hurting some default Dummy NPCs I put into the game; I did not remove/change anything inside the Dummies, other than moving them around the map to better locations.
Here's the script I have inside the Fireball mesh that's supposed to detect when it's touching something:
script.Parent.Touched:Connect(function(part) print("Part was touched, Parent name is "..part.Parent.Name) local parent = part.Parent local humanoid = parent:FindFirstChild("Humanoid") if humanoid then local player = game.Players:GetPlayerFromCharacter(parent) if not (script.Parent.Parent.Owner.Value == player) then -- All this does is make it where the person throwing the fireball doesn't get hurt humanoid.Health = parent.Humanoid.Health - 30 end end end)
Whenever I use the fireball and throw it at an NPC, it doesn't even print "Part was touched blah blah blah", which means it didn't even detect it hitting the NPC. How would I fix this?
Thanks for trying to help, I appreciate it
I was able to get it to work by deleting the owner function.
script.Parent.Touched:Connect(function(part) print("Part was touched, Parent name is "..part.Parent.Name) local parent = part.Parent local humanoid = parent:FindFirstChild("Humanoid") if humanoid then local player = game.Players:GetPlayerFromCharacter(parent) if not (script.Parent.Parent == player) then -- All this does is make it where the person throwing the fireball doesn't get hurt humanoid.Health = parent.Humanoid.Health - 30 end end end)
Bruhhhh. Ok, so the problem was that the NPCs were anchored lol. Sorry, the NPC's props never crossed my mind.