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

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

Asked by 3 years ago

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)
0
instead of doing fireserver(player, something_else) just do fireserver(something_else) without the player keep everything else the same BulletproofVast 1033 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

Ad

Answer this question