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

Is there an error with the variable?

Asked by 7 years ago
Edited 7 years ago
local pl = script.Parent.Parent.TextBox.Text




local topkek = script.Parent.Text


script.Parent.MouseButton1Down:connect(function()
    game:GetService('TeleportService'):Teleport(471383497, game.Players.pl)
end)


I'm not sure as to why an error is occuring.

*13:01:22.378 - pl is not a valid member of Players 13:01:22.379 - Stack Begin 13:01:22.380 - Script 'Players.derfvb123.PlayerGui.ScreenGui.lel.LocalScript', Line 10 13:01:22.381 - Stack End *

2 answers

Log in to vote
2
Answered by 7 years ago

The problem is that you are trying to find a member of players called pl. You need to find the player whose name is equal to the value of pl, using the index operator:

local pl = script.Parent.Parent.TextBox.Text




local topkek = script.Parent.Text


script.Parent.MouseButton1Down:connect(function()
    game:GetService('TeleportService'):Teleport(471383497, game.Players[pl])
end)



Ad
Log in to vote
0
Answered by
daricr 0
7 years ago

The issue is, that error comes up when you try and call a variable in a direct manner. You need to find the object with the value equal to "pl".

Refer to this ROBLOX Wiki Article to help you out; Click Me!

Answer this question