Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is .Touched not working?(more details)

Asked by 4 years ago

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

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. Vegetta0121 22 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

0
I have no clue how to use bodyposition so i just used body velocity with no velocity for it and thx :). HappyTimIsHim 652 — 4y
Ad
Log in to vote
0
Answered by
0_2k 496 Moderation Voter
4 years ago
Edited 4 years ago

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.

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 HappyTimIsHim 652 — 4y
0
if you were a considered skilled scripter i'd kms bhqpping 80 — 4y
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_2k 496 — 4y
0
it doesn't print even though it touched HappyTimIsHim 652 — 4y
View all comments (3 more)
0
i already changed it to FindFirstChild("Humanoid") then HappyTimIsHim 652 — 4y
0
Is it a local script? 0_2k 496 — 4y
0
nope HappyTimIsHim 652 — 4y

Answer this question