Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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.

0
Can you use a code block? Your code is near impossible to comprehend like this. lunatic5 409 — 6y
0
Yea, one moment, i'm new to the site. Professor_Hew 10 — 6y
0
Oh, it's alright. I'll try to find the problem. lunatic5 409 — 6y
0
connect and children are deprecated use Connect and GetChildren User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago

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

0
Do you know any way i can prevent it from saying "Name here" when i input the text? Professor_Hew 10 — 6y
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 chomboghai 2044 — 6y
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! Professor_Hew 10 — 6y
Ad

Answer this question