Remote Events Error!

I’m making something like when Player A clicked Player B’s body, a Gui appears in Player A and a text say Player B’s Name… However, I met a problem. It says “unable to cast value to object”

ClickD.MouseClick:Connect(function(wasclicked)
	print(wasclicked) --print who clicked
		
	REGETUI2:FireClient(ClickD:FindFirstChildWhichIsA("StringValue").Name)
end)	

ClickD is the ClickDetector
REGETUI2 is the Remote Event
StringValue is the name of the player who was clicked

Ui text script:

re2.OnClientEvent:Connect(function(whowasclicked)
	script.Parent.Namee.Text = whowasclicked.Name
end)

Can anyone help?

1 Like

The first parameter in FireClient has to be the specific player you want to fire the event to

	REGETUI2:FireClient(ClickD:FindFirstChildWhichIsA("StringValue").Name)

Should be

	REGETUI2:FireClient(wasclicked,ClickD:FindFirstChildWhichIsA("StringValue").Name)

Edit: Okay so I should’ve read the description correctly, your issue is here

script.Parent.Namee.Text = whowasclicked.Name

Remove the .Name, you alreayd gave the name when firing the client

1 Like

Everything works! Thank you so much!

1 Like

Anytime! I recommend marking my post as the solution if it helped you so others will easily know the issue if they stumble upon it too! If you have any more issues don’t be afraid to make another post!