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

How Do You Make The Player's Head Invisible By Function onClicked()?

Asked by 8 years ago

How do you make the player's head invisible by changing the head's transparency to 1 when the part is clicked?

local debounce = true

function onClicked()
    if debounce == true then
        debounce = false
        --Make the player's head invisible by changing the head's transparency to 1.
        debounce = true
    end
end

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

1 answer

Log in to vote
1
Answered by
rexbit 707 Moderation Voter
8 years ago

ROBLOX actually had an arument for the player who created contact with the ClickDetector imputed by the Part.

local debounce = true

function onClicked(playerWhoClicked)
    if debounce == true then
        debounce = false
        playerWhoClicked.Character:WaitForChild("Head").Transparency = 1
        wait(1) -- without a wait, it's not a true debounce.
        debounce = true
    end
end

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

0
Thanks it worked! One more question, you can ignore this if you want, is there an official word instead of "playerWhoClicked"? GatitosMansion 187 — 8y
0
Yes! An argument is a varible with value passed through a function. Just think of it as a variable! rexbit 707 — 8y
Ad

Answer this question