Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is .Touched not working?(more details)

The title says it, i cannot find out what's wrong.

plr = game.Players[script.Parent.Parent.Name]
kamehameha = script.Parent
kamehameha.Touched:Connect(function(hit)
	print("touched")
	if hit.Parent:FindFirstChild("Humanoid") == true then
		humtodmg = hit.Parent:FindFirstChild("Humanoid")
		humtodmg.Health = humtodmg.Health - plr.Stats.KiMax/10
	end
end)

also this script is disabled and it gets undisabled when this script copies it into a part.

	blast = Instance.new("Part")
	blast.Name = "blast"
	blast.Shape = "Cylinder"
	blast.BrickColor = BrickColor.new("Toothpaste")
	blast.Transparency = 0.1
	blast.Material = "Neon"
	blast.CFrame = CFrame.new(ctr.HumanoidRootPart.CFrame.lookVector * 39 + ctr.HumanoidRootPart.CFrame.Position)
	blast.CFrame = CFrame.new(blast.CFrame.Position, ctr.HumanoidRootPart.CFrame.Position) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
	blast.Anchored = true
	clone2 = clone:Clone()
	clone2.Parent = blast
	clone2.Disabled = false
	clone2 = nil
	blast.Size = Vector3.new(75,5,5)
	blast.CanCollide = false
	blast.Parent = ctr

clone2 is the clone of the script on the top

1 comment

0

Maybe try not to anchor the kamehameha but give it a bodyvelocitiy with a very small velocity and set the maxforce of the bodyvelocity to math.huge.

2 answers

✓ Accepted answer

Roblox parts that are...

  1. Anchored = true
  2. CanCollide = false

Do NOT have physics calculated on them. While looking at the DevHub for the .Touched event you can see that it will only fire as a result of physics movement. That may be why its not working. You could try setting anchored = false and trying to use something like a BodyPosition to keep the blast in place.

Alternatively you could try using Magnitude and testing the distance between the part and a player, or Region3 and checking to see if the player is inside the area of the blast.

1 comment

0

I have no clue how to use bodyposition so i just used body velocity with no velocity for it and thx :).

hit.Parent:FindFirstChild("Humanoid") == true is the possible error... Doing if hit.Parent:FindFirstChild("Humanoid") or if not hit.Parent:FindFirstChild("Humanoid") work for sure, unsure if it'd help.

7 comments

0

ummm ok??? well that's not the problem you see before that Touched isn't printing which means that's not the error and i'm also a pretty skilled scripter and i know FindFirstChild("Humanoid") == true is not the error

0

if you were a considered skilled scripter i'd kms

0

The script yields once it gets to that line, printing only tells you that it was touched, has nothing to do with finding the humanoid. If it wasn't the error, I'm pretty sure it wouldn't be yielding anytime after that.

0

it doesn't print even though it touched

0

i already changed it to FindFirstChild("Humanoid") then

0

Is it a local script?

0

nope

This discussion is preserved as it was. New answers, comments, and votes are closed.