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.
Please try this:
--// Initialization local GamePassService = game:GetService("GamePassService") --// Variables gamepass1 = 256633733 --// Functions function onCharacterSpawn(character) local player = game.Players:GetPlayerFromCharacter(character) if GamePassService:PlayerHasPass(player, gamepass1) then script.Parent.Parent.Spawn.Visible = true script.Parent.Visible = false script.Parent.Parent.Parent.OwnedBikes.Bike12.Visible = true end end --// Triggers game.Workspace.ChildAdded:connect(onCharacterSpawn)
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 else end end game.Workspace.ChildAdded:connect(respawned)
Adding an else will tell the script that if something doesn't happen or has happened, etc, do this. So if OwnedBikes.Bike12.Visible = false then it will remove.