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

Text is not a valid member of Player?

Asked by 3 years ago
Edited 3 years ago

In the Server Script below I'm trying to clone a Billboard GUI that will be above the player's read and show the result of a math.random which is the result of a dice roll, I am cloning the Billboard GUI and parenting it to the player so it is shown above their head, the problem is that I'm using a RemoteEvent to send two datas, the player and the rollnumber which is the result, everything works until that line "DiceResult.TextLabel.Text = rollnumber.Text" where it says: Text is not a valid member of Player, could someone help me with that? I know that probably there is an easy fix to that but it is a problem so specific that I couldn't find others similar so I had to ask here, I appreciate the help.

Local Script activated through a button:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DiceRoll = ReplicatedStorage.DiceRoll

local player = game:GetService("Players").LocalPlayer

numbers = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
roll = script.Parent.Window.Roll
rollnumber = script.Parent.Window.Number
enabled = true
roll.MouseButton1Down:connect(function()
    if enabled == true then
    rollnumber.Text = math.random(1,#numbers)
    script.Parent.Sound:Play()
    enabled = false
    DiceRoll:FireServer(player, rollnumber)
    wait(10)
    enabled = true
    end
end)

Server Script activated through the RemoteEvent:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local DiceRoll = ReplicatedStorage.DiceRoll
local Namer = ServerStorage.Namer

local function RollADice(player, rollnumber)
    local DiceResult = Namer:Clone()
    DiceResult.Name = "DiceResult"
    DiceResult.Parent = player.Character.Head
    DiceResult.TextLabel.Text = rollnumber.Text
    wait(10)
    DiceResult:Destroy()
end

DiceRoll.OnServerEvent:Connect(RollADice)
0
EDIT: I decided to add the Local Script so you guys could have more information to use to help me out. Kaisarys 19 — 3y

2 answers

Log in to vote
0
Answered by
ImTrev 344 Moderation Voter
3 years ago
Edited 3 years ago

What I'm guessing is you're firing the event like this: :FireServer(Player, rollnumber). If I am right then you should be firing the server like this: :FireServer(rollnumber) because the server automatically gets the player so you don't have to input that parameter. If I am wrong please tell me and we can further debug.

EDIT: With full scripts

Try this: Local Script - Line 15: DiceRoll:FireServer(rollnumber)

EDIT 2: Server Script

Line 10: DiceResult.TextLabel.Text = rollnumber

EDIT 3: Local Script

DiceRoll:FireServer(rollnumber.Text)

0
I already tried doing this, but the player on line 9 gets redlined and the output says "attempt to index nil with 'Character'" so I assumed that the player was a parameter that I needed to put there. Kaisarys 19 — 3y
0
Player needs to be a parameter in the RollADice function but not in the FireServer. Can you provide the FireServer line in your LocalScript. ImTrev 344 — 3y
0
I edited my question and included the entire LocalScript to make it easier for everyone to understand what I'm trying to do. Kaisarys 19 — 3y
0
Try the new edit ImTrev 344 — 3y
View all comments (6 more)
0
Now there are no errors, but the Billboard GUI simply won't show up while before it would appear with the default Text "Label" Kaisarys 19 — 3y
0
Try this, sorry I just can't think straight today. ImTrev 344 — 3y
0
Now the Billboard GUI shows up just like before with the default Text followed by the erros: ServerScriptService.Script:10: invalid argument #3 (string expected, got Instance) Kaisarys 19 — 3y
0
Try DiceRoll:FireServer(rollnumber.Text) ImTrev 344 — 3y
0
It worked finally just as I wanted. Thank you for helping me out and mainly for the patience. I'll accept your answer right now. Kaisarys 19 — 3y
0
Thank you and you're welcome. Hope all goes well with what you're making! If you need anymore help we are here! ImTrev 344 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

The error is because of the last line in your script, OnServerEvent returns the player as the first argument, so you have essentially stored the player in the RollADice variable, change the final line to:

DiceRoll.OnServerEvent:Connect(player, RollADice)

Hope this helps.

EDIT: You also don't need the "player" in the FireServer() bit, that is already returned to the server in the first argument when you use OnServerEvent.

0
It says unknown global player. Kaisarys 19 — 3y
0
What script is it saying it for and what line? PhantomBrix 40 — 3y
0
Server Script Line 15. Kaisarys 19 — 3y
0
That's because in the LocalScript at Line 15 you have the "player" variable in the brackets, that will throw an error because the server already knows which player fired the server, so the error is saying you're passing a variable that doesn't exist. It should be FireServer(rollnumber) PhantomBrix 40 — 3y

Answer this question