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

Getting Error "is not a valid member of Players"?

Asked by 5 years ago
Player = script.Parent.Parent.Parent.Parent.Main.Selecteduser.User.Text
EconomyAgree = script.Parent.Parent.Parent.Parent.EconomyAgree

script.Parent.MouseButton1Click:Connect(function()
    game.Players[Player].PlayerGui.ManualCheckInConfirm.Economy:TweenPosition(UDim2.new(.33,0,.714,0))
    EconomyAgree:TweenPosition(UDim2.new(.042,0,.652,0))
    EconomyAgree.Visible = false
end)

I have a script but it says that the line "game.Players[Player]" is not a valid member of Players but Player has a name in it.

0
Is this a local script or a regular script? 123nabilben123 499 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

With the game.Players[Player] Line I think you'd want to use a Tostring of the player using the text so while inside a FindFirstChild. So the script will be searching the Players Section to find the player and you are converting the tostring to text.

Player = script.Parent.Parent.Parent.Parent.Main.Selecteduser.User.Text
EconomyAgree = script.Parent.Parent.Parent.Parent.EconomyAgree

script.Parent.MouseButton1Click:Connect(function()
    game.Players:FindFirstChild(tostring(Player)).PlayerGui.ManualCheckInConfirm.Economy:TweenPosition(UDim2.new(.33,0,.714,0))
    EconomyAgree:TweenPosition(UDim2.new(.042,0,.652,0))
    EconomyAgree.Visible = false
end)

Hope this helps. I haven't tested it for myself but if it does, accept this answer please.

0
I get this error now! " - Players.DennisSense.PlayerGui.ScreenGui.EconomyAgree.Submit.TextButton.Script:11: attempt to index a nil value" DennisSense 23 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Player = script.Parent.Parent.Parent.Parent.Main.Selecteduser.User
EconomyAgree = script.Parent.Parent.Parent.Parent.EconomyAgree

script.Parent.MouseButton1Click:Connect(function()
    game.Players[Player.Text].PlayerGui.ManualCheckInConfirm.Economy:TweenPosition(UDim2.new(.33,0,.714,0))
    EconomyAgree:TweenPosition(UDim2.new(.042,0,.652,0))
    EconomyAgree.Visible = false
end)

This worked, make sure you put it in a Local Script!

Answer this question