So I want to make a game where if the player clicks on a button, their character dies. The only problem is, whenever I try to reference the player using "Player", the console says that "Player is not a valid member of workspace", and when I tried referencing Players instead of workspace, I pretty much got the same error.
I'm new to scripting so I decided to borrow some code and modify it, this is the code:
local script:
local ClickDetector = game.Workspace.Button.ClickDetector --Sets variable for clickdetector
ClickDetector.MouseClick:Connect(function() -- declares function for click event
game.Workspace.ClickEvent:FireServer() -- fires server
end)
serverscript:
game.Workspace.ClickEvent.OnServerEvent:Connect(function()
end)
the serverscript is empty because I couldn't figure out how to reference the player and set their health to 0.
Any help would be appreciated.

1 comment
Try looking stuff up in the API Reference before you ask, It's a very helpful resource https://developer.roblox.com/en-us/api-reference/