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

How would I do a function to a other part?

Asked by 9 years ago

What I mean is like saying, if a part is somewhere, and it touches a other part, it does the function to that part, and not the players.

My guess is that it goes something like this :

function onTouch(touched)
    if script.Parent.Touched:connect ~= humanoid then
    end
    if script.Parent.Touched:connect == humanoid then
    end
end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

The way you worded it is a bit confusing. Let me get this right. If you're trying to make the code run, if the object that touched a part is NOT a player, then here you go:

script.Parent.Touched:connect(function(hit)
    if not game.Players:GetPlayeFromCharacter(hit.Parent) then
        -- Your code
    end
end)

If you want it to run if it's a player, remove the "not" in line 2!

Ad

Answer this question