✓ Accepted answer
You might want to use PlayerGui, so it only works for the player who clicked it.
To get the player, we can use a player added event.
Script:
game.Players.PlayerAdded:Connect(
function(player)
print(player.Name)
end
)
Now, once we've done that, we'll have to detect if the player clicks the part.
game.Players.PlayerAdded:Connect(
function(player)
print(player.Name)
local ClickDetector = workspace.Volcano.Keypad.ClickDetector
function onMouseClick()
print("Clicked)")
end
ClickDetector.MouseClick:Connect(onMouseClick)
end
)
After that, we'll have to make it toggle enabled. To do this, we'll just have to do an if statement detecting if it's enabled or not.
game.Players.PlayerAdded:Connect(
function(player)
print(player.Name)
local ClickDetector = workspace.Volcano.Keypad.ClickDetector
function onMouseClick()
print("Clicked)")
if player.PlayerGui.Keypad.Enabled == false then
player.PlayerGui.Keypad.Enabled = true
else
player.PlayerGui.Keypad.Enabled = false
end
end
ClickDetector.MouseClick:Connect(onMouseClick)
end
)
Accept the answer if it worked.
4 comments
use playergui instead
how do you refer to playergui?
edited
^