Roleplay Name System Error

Hey everyone. I’m trying to make a roleplay name system and as you will probably be able to tell, I am not an experienced scripter. I’m having trouble getting the player-inputted text over to the server to be displayed. These are my two scripts to far:

-- LOCALSCRIPT
local namesettings = script.Parent.nametagsettings
local open = script.Parent.openbutton
namesettings.Visible = false
local textbox = namesettings.TextBox


open.MouseButton1Click:Connect(function()
	if namesettings.Visible == false then
		namesettings.Visible = true
	else
		namesettings.Visible = false
	end
end)

namesettings.Apply.MouseButton1Click:Connect(function()
	game:GetService("ReplicatedStorage"):WaitForChild("NameChangeEvent"):FireServer(textbox.Text,game.Players.LocalPlayer)
end)
-- SERVERSCRIPT
local nametag = script.NameTag
local display = nametag.Display
local name = nametag.pName

game.Players.PlayerAdded:Connect(function(player)
	local currentname = Instance.new("StringValue")
	currentname.Name = "currentname"
	currentname.Parent = player
	player.CharacterAdded:Connect(function(char)
		repeat wait() until char.Head
		local tagclone = nametag:Clone()
		tagclone.Parent = char.Head
		tagclone.Display.Text = player.DisplayName
		tagclone.pName.Text = "@"..player.Name
	end)
end)

game:GetService("ReplicatedStorage"):WaitForChild("NameChangeEvent").OnServerEvent:Connect(function(text,player)
	print(tostring(player))
	print(tostring(text))
	player.Character:FindFirstChild("Head"):WaitForChild("NameTag").Display.Text = text
end)

As you can see, the name is above the player’s head. That works fine. It’s just it doesn’t change when the player clicks ‘apply’

Thanks for any help.

1 Like

Instead of

game:GetService("ReplicatedStorage"):WaitForChild("NameChangeEvent").OnServerEvent:Connect(function(text,player)

change it to

game:GetService("ReplicatedStorage"):WaitForChild("NameChangeEvent").OnServerEvent:Connect(function(Player, text)

And also set the client script to :FireServer(textbox.Text) only. While “OnServerEvent”, there’s already “player” (the player who’s fired to server) on first argument and the next are the rest.

Hope this helps.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.