I have this code which makes a GUI visible when a player owns a GUI. Does anyone know a way to make this code more, reliable?
Likewise, people who own it sometimes still see the [BUY NOW] button instead!
passid = 256633733
local GamePassService = game:GetService("GamePassService")
function respawned(char)
local player = game.Players:FindFirstChild(char.Name)
if GamePassService:PlayerHasPass(player, passid) then
script.Parent.Parent.Spawn.Visible = true
script.Parent.Visible = false
script.Parent.Parent.Parent.OwnedBikes.Bike12.Visible = true
end
end
game.Workspace.ChildAdded:connect(respawned)
Cheers,
Michael
This is the Hierarchy of the script. The Red arrow is where this code is located.

4 comments
can you provide the hierarchy please?
Edited question!
are you doing it on studio or on a roblox server?
Roblox server.