I have this script that is 'supposed' to work, but if the player doesn't own the gamepass, they still get the gui, what's wrong?
Players = game:GetService("Players") gps = game:GetService("GamePassService") id = 266394204 --the gamepass id VIP = {"Adelenia","NotSoNorm"} --special VIP players players = game.Players:GetPlayers() GUI = script.GUI NewGui = nil Player = nil Active = false Seat = script.Parent script.Parent.ChildAdded:connect(function(Child) print("1pass") if Active == false then print("2pass") if Child.Name == "SeatWeld" then print("3pass") Active = true Player = Players:GetPlayerFromCharacter(Child.Part1.Parent) if Child.Parent.Parent.Parent.Name == VIP[1] or VIP[2] or VIP[3] or gps:PlayerHasPass(Player, id) then print("4pass") local PlayerGui = Player:FindFirstChild("PlayerGui") if PlayerGui ~= nil then NewGui = GUI:Clone() NewGui.Parent = PlayerGui else end end end end end) Seat.ChildRemoved:connect(function(child) if child.Name == "SeatWeld" then if Active == true then Active = false local Getchil = script.Parent.Parent.Colors:GetChildren() for i = 1, #Getchil do Getchil[i].BrickColor = BrickColor.new("Navy blue") Getchil[i].Material = Enum.Material.Plastic end pcall(function() NewGui:Destroy() end) Player = nil NewGui = nil end end end)
Your problem is that you're not re-defining each condition in your if statement. You have this:
if Child.Parent.Parent.Parent.Name == VIP[1] or VIP[2] or VIP[3] or gps:PlayerHasPass(Player, id) then
Let me break it down into parts of what this would be doing:
• If Player.Name is Adelenia then continue
or • If there is a second value in the table "VIP" then continue
or • If there is a second value in the table "VIP" then continue
or • If Player has gamepass then continue
So, to fix this, all we need to do is completely re-define each condition before this will work correctly. All you need to do is this:
if Child.Parent.Parent.Parent.Name == VIP[1] or Child.Parent.Parent.Parent.Name == VIP[2] or Child.Parent.Parent.Parent.Name == VIP[3] or gps:PlayerHasPass(Player, id) then
So, let's now insert this into the rest of your script. It will look like this:
Players = game:GetService("Players") gps = game:GetService("GamePassService") id = 266394204 --the gamepass id VIP = {"Adelenia","NotSoNorm"} --special VIP players players = game.Players:GetPlayers() GUI = script.GUI NewGui = nil Player = nil Active = false Seat = script.Parent script.Parent.ChildAdded:connect(function(Child) print("1pass") if Active == false then print("2pass") if Child.Name == "SeatWeld" then print("3pass") Active = true Player = Players:GetPlayerFromCharacter(Child.Part1.Parent) if Child.Parent.Parent.Parent.Name == VIP[1] or Child.Parent.Parent.Parent.Name == VIP[2] or Child.Parent.Parent.Parent.Name == VIP[3] or gps:PlayerHasPass(Player, id) then print("4pass") local PlayerGui = Player:FindFirstChild("PlayerGui") if PlayerGui ~= nil then NewGui = GUI:Clone() NewGui.Parent = PlayerGui else end end end end end) Seat.ChildRemoved:connect(function(child) if child.Name == "SeatWeld" then if Active == true then Active = false local Getchil = script.Parent.Parent.Colors:GetChildren() for i = 1, #Getchil do Getchil[i].BrickColor = BrickColor.new("Navy blue") Getchil[i].Material = Enum.Material.Plastic end pcall(function() NewGui:Destroy() end) Player = nil NewGui = nil end end end)
So basically that was your only problem. Remember that you need to always re-define each condition.
Anyways, if you have any further problems/questions, please leave a comment below. Hope I helped :P