Instance with string error

Hi! So I am trying to make it so when a player touches the part, a message will show up in chat. Here is part of the script:

part.Touched:Connect(function(hit)
	print("started")
	if hit.Parent:FindFirstChild("Humanoid") then
		game.StarterGui:SetCore('ChatMakeSystemMessage', {
			Text = player.."has finished the logo quiz!";
			Font = Enum.Font.SourceSansBold;
			Color = BrickColor.new('Fire Yellow');
			FontSize = Enum.FontSize.Size24;
			
			
			
			
			
		}

I am getting an error saying:

How do I fix this?

2 Likes

Try player.Name, not player.

Its because you are putting an instance inside the string, because player returns a player, bot a string.

1 Like

Try this:

	print("started")
	if hit.Parent:FindFirstChild("Humanoid") then
		game.StarterGui:SetCore('ChatMakeSystemMessage', {
			Text = player.Name .." has finished the logo quiz!"; -- Changed line
			Font = Enum.Font.SourceSansBold;
			Color = BrickColor.new('Fire Yellow');
			FontSize = Enum.FontSize.Size24;
			
			
			
			
			
		}
1 Like

What is the player defined as? This will clearly not work, try this

hit.Parent.Name.."has finished the logo quiz!";
2 Likes

I think they are using a local script so they will already have the player

Using a local script won’t detect when a part is touched + it wont get the player who touched, it will get the local player

I have it in starterplayerscripts so I can use a local script.

You shouldn’t use a local script to detect the .Touched event (its un-detectable on the client)
Use the line i gave you in a SERVER script, it will fix it

It is detectable if I put the local script in the folder starterplayerscripts. It works fine now.

1 Like

If you already marked the post as a solution, isn’t your problem already solved and everything is working fine?

Then explain to me why it is working perfectly fine?

1 Like

Yes, everything is working fine. Thanks for your help.