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 4 years ago
Edited 4 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:

01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02local DiceRoll = ReplicatedStorage.DiceRoll
03 
04local player = game:GetService("Players").LocalPlayer
05 
06numbers = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
07roll = script.Parent.Window.Roll
08rollnumber = script.Parent.Window.Number
09enabled = true
10roll.MouseButton1Down:connect(function()
11    if enabled == true then
12    rollnumber.Text = math.random(1,#numbers)
13    script.Parent.Sound:Play()
14    enabled = false
15    DiceRoll:FireServer(player, rollnumber)
16    wait(10)
17    enabled = true
18    end
19end)

Server Script activated through the RemoteEvent:

01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02local ServerStorage = game:GetService("ServerStorage")
03local DiceRoll = ReplicatedStorage.DiceRoll
04local Namer = ServerStorage.Namer
05 
06local function RollADice(player, rollnumber)
07    local DiceResult = Namer:Clone()
08    DiceResult.Name = "DiceResult"
09    DiceResult.Parent = player.Character.Head
10    DiceResult.TextLabel.Text = rollnumber.Text
11    wait(10)
12    DiceResult:Destroy()
13end
14 
15DiceRoll.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 — 4y

2 answers

Log in to vote
0
Answered by
ImTrev 344 Moderation Voter
4 years ago
Edited 4 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 — 4y
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 — 4y
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 — 4y
0
Try the new edit ImTrev 344 — 4y
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 — 4y
0
Try this, sorry I just can't think straight today. ImTrev 344 — 4y
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 — 4y
0
Try DiceRoll:FireServer(rollnumber.Text) ImTrev 344 — 4y
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 — 4y
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 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 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:

1DiceRoll.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 — 4y
0
What script is it saying it for and what line? PhantomBrix 40 — 4y
0
Server Script Line 15. Kaisarys 19 — 4y
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 — 4y

Answer this question