Make sure your script is a localscript.
Since server scripts can’t get textbox input from a client, if you want to send textbox text to the server then use remote events.
This was a part of my game, you might have to change it a bit to get it to work for your game (Ik it looks horrendous to look at, but I made it when I was starting ) :
local MarketPlace = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local Service = game:GetService("GamePassService")
local BackgroundLinkHolder = script.Parent.Parent.Parent.PaidLinkBack.TextBox
script.Parent.MouseButton1Click:Connect(function()
game.StarterPlayer.StarterPlayerScripts.Sounds.MouseClick:Play()
game.StarterPlayer.StarterPlayerScripts.Sounds.MouseClick.TimePosition = 1
if Service:PlayerHasPass(player, GamePassId) then
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Image = string.format("rbxthumb://type=Asset&id=%s&w=768&h=432", BackgroundLinkHolder.Text)
else
MarketPlace:PromptGamePassPurchase(player, GamePassId)
warn(player.Name .. "does not have the gamepass")
end
end)