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

Is there a way to have an VIP/Owner only ClickDetector?

Asked by
Nidoxs 190
8 years ago

Could you maybe get the player from the Click and check the name? I am unsure of this... Here is what I tried. I tried to use click like you would use a hit on the touched event.

function click(click)
    if click.Parent.Name == "doctorbenny2011" then 
        print("Test Passed")
    else
        print("Test Failed")
    end
end

script.Parent.ClickDetector.MouseClick:connect(click)

1 answer

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
8 years ago

Should be:

function click(click)
    if click.Name == "Player" or click.Name=="doctorbenny2011"  then -- click is the player that clicks the `ClickDetector`
        print("Test Passed") -- successfully prints `Test Passed`
    else
        print("Test Failed")
    end
end

script.Parent.ClickDetector.MouseClick:connect(click)

click gains access to the player, if we place click.Parent that will lead us to Playerscontainer.

0
WOW! Thanks alot I didn't think this would be possible! :) Nidoxs 190 — 8y
0
You should make an edit that shows how to do it with arrays aswell, since it is useful for multiple names DigitalVeer 1473 — 8y
Ad

Answer this question