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.
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
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.
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.