Player Name in Server Script Not working

Hi, there. I’m trying to make a register with a button, which button when you click it, it claims the register and displays on it who claimed it.

The main issue I’ve encountered is not being able to display on it who has claimed it (the username of the player), using a server script.

I’ve tried changing the parent for Player, but that didn’t seem to work.

Here’s the main script:

local Claimed = false

function ClaimRegister(Player)
	if Claimed == false then
		Claimed = true
		script.Parent.Display.ClaimButton.Text = "Unclaim"
		script.Parent.Display.TextLabel.Text = "Claimed by "..Player.Name
		wait(1)
	elseif Claimed == true then
		Claimed = false
		script.Parent.Display.ClaimButton.Text = "Claim"
		script.Parent.Display.TextLabel.Text = "Claim"
	end
end

script.Parent.Display.ClaimButton.MouseButton1Down:Connect(ClaimRegister)

image

I don’t have much knowledge about scripting. I can mainly do basic tasks.
The error I’m receiving:
image

In which line does the error occur?

In the 7th line, (script.Parent.Display.TextLabel.Text = "Claimed by "…Player.Name)

Can you try print(script) becuz it looks like script refers to a number ( according to the error )

this is the original error:


I forgot I had changed it with “Parent”

Oh, ok, do tostring(Player).Name or print Player

image
Not sure why it’s in numbers. The script thinks it’s a number.

MouseButton1Down doesn’t return the player, it returns x,y position of the mouse position in 2d space. Make it a local script

1 Like

Actually, I tried doing it with a ClickDetector since it’s a server script and it’s supposed to be, which worked for me instead! Thanks for the advice anyway. :smiley:

1 Like

Ye, no problem. You can use remote events also, if you wanted to use the prev method

1 Like