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

Umm. Can someone help me with this? I can't seems to fix this Touched event?????????

Asked by 5 years ago
function hit()
    print("got it")
    if hit.Parent:FindFirstChild("Humanoid") then
        print("ayy")
    end
end 
script.Parent.Lighten.Touched:Connect(hit)
script.Parent.Lighten2.Touched:Connect(hit)

It's in a script which has other things too It doesn't print anything too.

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Here's a proper example of how to use .Touched

--we can do this one of two ways:

local part = workspace.Part --for example

part.Touched:Connect(function(PartThatTouched)
    if PartThatTouched.Parent:FindFirstChild("Humanoid") then
        print(PartThatTouched.Name)
    end
end)

--or we can use a named function

function OnTouch(PartThatTouched)
    if PartThatTouched.Parent:FindFirstChild("Humanoid") then
        print(PartThatTouched.Name)
    end
end

part.Touched:Connect(OnTouch)
0
fail, the humanoid won't be inside the part User#19524 175 — 5y
0
my bad xd Gey4Jesus69 2705 — 5y
Ad

Answer this question