Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Getting an issue with "Text is not a valid member of player"?

I've tried making a name gui that connects client - server, however, it keeps erroring.

Local:

repeat wait() until game.Players.LocalPlayer~=nil
chat=game:GetService("Chat")
v=game.Players.LocalPlayer
local char=v.Character
remeven=script.Parent.Parent:WaitForChild("NameTrigger")
ten=script.Parent
script.Parent.FocusLost:connect(function(enter)
	if enter then
		remeven:FireServer(v,ten)
		print("connected")
	end
end)

Remote:

chat=game:GetService("Chat")
script.Parent.OnServerEvent:connect(function (tens,player)
		for a, mod in pairs(player.Character.Head:children()) do
			if mod.Name==("NameGui") then
			 mod:Destroy()
			end
		end
		wait(0.1)
		local B= Instance.new("BillboardGui")
		B.Parent=player.Character.Head
		B.Name="NameGui"
		B.Size=UDim2.new(1,0,1,0)
		B.ExtentsOffset=Vector3.new(0,3,0)
		B.LightInfluence=0
		local T=Instance.new("TextLabel")
		T.Parent=player.Character.Head.NameGui
		T.Text = chat:FilterStringForBroadcast(tens.Text,player)
		T.Font="Arcade"
		T.Size=UDim2.new(1,0,1,0)
		T.TextSize=30
		T.TextColor3= Color3.new(255,255,255)
		T.BackgroundTransparency=1
		T.BorderSizePixel=0
		T.TextStrokeTransparency=0
		T.TextStrokeColor3=Color3.new(0,0,0)
end)

It confuses tens.Text for player.Text, and i don't quite understand why.

4 comments

0

Can you use a code block? Your code is near impossible to comprehend like this.

0

Yea, one moment, i'm new to the site.

0

Oh, it's alright. I'll try to find the problem.

0

connect and children are deprecated use Connect and GetChildren

1 answer

When you use :FireServer(), an argument is already passed in, and that argument is the player.

So if you use FireServer() with no arguments, your OnServerEvent should have one parameter, the player.

remote:FireServer(content)
-----------------------
remote.OnServerEvent:Connect(function(player, content)
	-- stuff
end)

Therefore, you should remove the v which is your player, and instead just have ten.

remeven:FireServer(ten)

then in your server script, listen for the parameters (player, ten)

script.Parent.OnServerEvent:Connect(function(player, tens)
	-- stuff
end)

Hope this helps! :)

3 comments

0

Do you know any way i can prevent it from saying "Name here" when i input the text?

0

Your code is very messy and the variable names are not helpful. I'm not sure what your script is supposed to do so I can't really help you until you give me a better understanding

0

Never mind, i fixed it. It was the use of unnecessary variables. I have cleaned it up a bit, and thanks for the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.