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

My remote event script isn't working and Idk why. Any help?

Sorry about bad grammar in the title, the character limit is awful. The error message says: Text is not a valid member of Player "Players.supercatsauthor"

Here are both scripts:

**--Localscript in StarterGui inside a text button waiting for a name to be typed into a textbox.**
local currentcamera = workspace.CurrentCamera

local player = game.Players.LocalPlayer

local event = game.ReplicatedStorage.Events:WaitForChild("Name_Server")

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Parent.Name_Box.Text ~= "" then
		
		local nametag = script.Parent.Parent.Name_Box
		player.Character.Head.BillboardGui.TextLabel.Text = nametag.Text
		
		event:FireServer(player, nametag.Text)
		print("fired")
		
		local ingame = script.Parent.Parent.Parent.Parent:WaitForChild("In-Game_GUI")
		ingame.Enabled = true
		
		repeat wait()
			currentcamera.CameraType = Enum.CameraType.Follow
		until currentcamera.CameraType == Enum.CameraType.Follow
		
		script.Parent.Parent.Position = UDim2.new(0.242, 0,-0.636, 0)
		
		script.Parent.Parent.Parent.LocalScript.Disabled = true
		
		script.Parent.Parent.Parent.Enabled = false
	else
		player.Character.Head.BillboardGui.TextLabel.Text = "Bob"
		
		event:FireServer(player, "Bob")
		print("fired")

		local ingame = script.Parent.Parent.Parent.Parent:WaitForChild("In-Game_GUI")
		ingame.Enabled = true

		repeat wait()
			currentcamera.CameraType = Enum.CameraType.Follow
		until currentcamera.CameraType == Enum.CameraType.Follow
		
		script.Parent.Parent.Position = UDim2.new(0.242, 0,-0.636, 0)
		
		script.Parent.Parent.Parent.LocalScript.Disabled = true
		
		script.Parent.Parent.Parent.Enabled = false
	end
end)
**--Script in serverscriptservice**

local event = game.ReplicatedStorage.Events:WaitForChild("Name_Server")

event.OnServerEvent:Connect(function(player, name)
	print("received")
	player.Character.Head.BillboardGui.TextLabel.Text = name.Text
	print("through")
end)

1 comment

0

instead of doing fireserver(player, something_else) just do fireserver(something_else) without the player keep everything else the same

1 answer

This is because when you fired the remote event, you dont send in the player. This is because when detect OnServerEvent, the player parameter is already there and is the first parameter. Because you sent in a player argument when there is automatically one already, you get 2 player arguments. Basically, the function in your script has 3 paramaters (player, player and nametag). You can simply fix this by removing the player argument like this

event:FireServer(nametag.Text)

Sorry if the explanation is confusing

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