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.
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! :)