UI text not changing for no reason

Hey!
In my Shop GUI, I have some text. It does not change for some reason. Why is that so?

local gamePassID = 13992448  
local MarketplaceService = game:GetService("MarketplaceService")
local function onPlayerAdded(character)

	local player = game:GetService("Players"):GetPlayerFromCharacter(character)
	local hasPass = false


	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)

	wait (7)
	if hasPass then
		coroutine.wrap(function()
			while true do

		
				wait (1)
				script.Parent.Text = "1 Out of 1 Gamepasses!" 
			end
		end)()
	else
		coroutine.wrap(function()
			while true do
				wait (1)
				script.Parent.Text = "0 Out of 1 Gamepasses!"
			end
		end)()
	end
end


onPlayerAdded(script.Parent) 
------------------2/2 text---------------
wait (5)
local Player = game.Players.LocalPlayer 
script.Parent.Text = Player.Name..", You own"

Why does it not work?
NOTE: This is before I have fully added support for DisplayNames. I only have it 50% added.

Are you receiving any errors in the Output window?

Not that I can see. It seems as if it’s working, but just not changing.

I presume script.Parent.Text is referring to the Text property of a TextLabel – if that is the case, I believe the issue may be coming down to the argument that is being sent into the function.

When you activate the onPlayerAdded function, you’re sending through script.Parent (which would be the TextLabel if what I mentioned in the first part of this post is correct), when it appears that you are expecting the Character to be sent through (based on the parameter name you setup).

And if this is a LocalScript, you shouldn’t need to add this:

local player = game:GetService("Players"):GetPlayerFromCharacter(character)

At the bottom of the script you reference the LocalPlayer, which could be moved to the top of the script, instead

local Player = game.Players.LocalPlayer 
1 Like


It’s working with my NameTag system though. The ____, You own is a Script and the 1/1 gamepasses is a LocalScript. The script in the Nametags is the same as the 1/1. It’s just been modified.

The localscript may be the cause of your problem if the script is in the player? Have you tried a script? :slight_smile:

This is still not fixed, and very dead.

Where is the script under, because you can’t change PlayerGUI objects through server scripts, if you want to change anything on the client relating to GUI you need to do it from the client.

Can you add this to the script and tell us what it prints?

...
local function onPlayerAdded(character)
    print(character:GetFullName())
    ...