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

Not a valid member of textbutton?

Asked by 6 years ago
Edited 6 years ago

Whenever I run this script the error "banned is not a valid member of textbutton," this script it not meant to be FE and when I test it on a non-FE environment this error come up. Here is the code

local player = game.Players
local button = script.Parent
local ew  = game.Players.LocalPlayer
local banned = script.Parent.banned.Value

script.Parent.MouseButton1Click:connect(function()

    if game.Players.LocalPlayer:IsInGroup(123980) then
                script.Parent.Text = "Welcome"
    else
        if game.Players.LocalPlayer.UserId == banned then
            script.Parent.Text = "You  are banned!" else

                script.Parent.Text = "Banned until you join the group!"
        wait(3)



        end


    end
end)

I put banned as a number value inside textbutton. Does anyone know the answer? This code is also inside a localscript. The group ID is also fake for my testing purposes. Also if I was to make this FE how would I do it?

1 answer

Log in to vote
0
Answered by 6 years ago

Chances are, the script is running before the number value loads in. You can fix it by using WaitForChild()

local banned = script.Parent:WaitForChild('banned').Value
Ad

Answer this question