Hello! I've made a vip room, and a vip door, which must tp into that room. But the door teleports only to the roof. Here's the script I've used
-------------------- --| WaitForChild |-- -------------------- -- Waits for parent.child to exist, then returns it local function WaitForChild(parent, childName) assert(parent, "ERROR: WaitForChild: parent is nil") while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end ----------------- --| Variables |-- ----------------- local GamePassService = game:GetService('MarketplaceService') local PlayersService = game:GetService('Players') local VipDoor = script.Parent local GamePassIdObject = script:WaitForChild( 'GamePassId') local JustTouched = {} ----------------- --| Functions |-- ----------------- -- Finds out which side the player is on and teleports them to the other local function TeleportToOtherSide(character, hitPart) local bottomOfDoor = VipDoor.CFrame.p - Vector3.new(0, VipDoor.Size.Y / 2, 0) local inFrontOfDoor = bottomOfDoor + VipDoor.CFrame.lookVector * 3 local behindDoor = bottomOfDoor - VipDoor.CFrame.lookVector * 3 local distanceToFront = (inFrontOfDoor - hitPart.Position).magnitude local distanceToBack = (behindDoor - hitPart.Position).magnitude if distanceToFront < distanceToBack then character:MoveTo(behindDoor) else character:MoveTo(inFrontOfDoor) end end -- When a player with the game pass touches the door, teleport them to the other side local function OnTouched(otherPart) if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then local player = PlayersService:GetPlayerFromCharacter(otherPart.Parent) if player and not JustTouched[player] then JustTouched[player] = time() if GamePassService:UserOwnsGamePassAsync(player.userId, GamePassIdObject.Value) then TeleportToOtherSide(player.Character, otherPart) end end end end -- Removes old entries in JustTouched local function RemoveOldTouches() for player, touchTime in pairs(JustTouched) do if time() > touchTime + 0.3 then JustTouched[player] = nil end end end -------------------- --| Script Logic |-- -------------------- VipDoor.Touched:connect(OnTouched) while true do RemoveOldTouches() wait(1/30) end
I've also used intvalue. Is there another way to make the vip door, like if u have the game pass, make a script which gives ability to go through the wall?
local Door = script.Parent local MarketplaceService = game:GetService("MarketplaceService") local GamePassId = 15657584 -- Change the number to 15664177 in Mega VIP Door.Touched:Connect(function() if MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer, GamePassId) Door.Transparency = 1 Door.CanCollide = false else MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, GamePassId) end end
local function TeleportToOtherSide(character, hitPart) local bottomOfDoor = VipDoor.CFrame.p - Vector3.new(0, VipDoor.Size.Y / 2, 0) local inFrontOfDoor = bottomOfDoor + VipDoor.CFrame.lookVector * 3 local behindDoor = bottomOfDoor - VipDoor.CFrame.lookVector * 3 local distanceToFront = (inFrontOfDoor - hitPart.Position).magnitude local distanceToBack = (behindDoor - hitPart.Position).magnitude if distanceToFront < distanceToBack then character:SetPrimaryPartCFrame(CFrame.new(behindDoor)) else character:SetPrimaryPartCFrame(CFrame.new(inFrontOfDoor)) end end
Answering on own question:
----------------------------------------------------------------------------------------------- ItemID = " " -- Change it for the ID of the Gamepass/T-Shirt. OpenTime = 0.9 -- The time the door is open for. OpenTrans = 1 -- The transparency of the door when it is open. CloseTrans = 0.85 -- The transparency of the door when it is closed. BuyGUI = true -- Set to false to stop the BuyGUI appearing. KillOnTouch = true -- Set to false to stop players being killed when they touch it. ----------------------------------------------------------------------------------------------- Door = script.Parent Serv = game:GetService("BadgeService") MServ = game:GetService("MarketplaceService") if not _G.Players then _G.Players = {[ItemID] = {}} elseif not _G.Players[ItemID] then _G.Players[ItemID] = {} end Table = _G.Players[ItemID] function CheckPlayer(player2) for i = 1,#Table do if Table[i] == player2 then return true end end return false end Door.Touched:connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) then player = game.Players:GetPlayerFromCharacter(hit.Parent) if MServ:UserOwnsGamePassAsync(player.userId,ItemID) or CheckPlayer(player) then Door.CanCollide = false Door.Transparency = OpenTrans wait(OpenTime) Door.CanCollide = true Door.Transparency = CloseTrans else Door.CanCollide = true Door.Transparency = CloseTrans if BuyGUI == true then MServ:PromptGamePassPurchase(player,ItemID) h = player.Character:FindFirstChild("Humanoid") if h then h.WalkSpeed = 0 end local con con = MServ.PromptGamePassPurchaseFinished:connect(function(ply,asset,purch) if ply == player and asset == ItemID then con:disconnect() if purch then if h then h.WalkSpeed = 16 end table.insert(Table,player) elseif KillOnTouch == true then Door.CanCollide = true Door.Transparency = CloseTrans player.Character:BreakJoints() end end end) elseif KillOnTouch == true then Door.CanCollide = true Door.Transparency = CloseTrans player.Character:BreakJoints() end end end end)