Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

Thanks it worked! One more question, you can ignore this if you want, is there an official word instead of "playerWhoClicked"?

0

Yes! An argument is a varible with value passed through a function. Just think of it as a variable!

This discussion is preserved as it was. New answers, comments, and votes are closed.