Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Vip door script not working as intended?

Asked by 4 years ago
Edited 4 years ago

So i have a script that makes the door cancollide false and the transparency to 1 if you have the gamepass but i wanna make it only open to me i tested it and the chasing npc i have could still go through it even tho it doesent have the gamepass. How can i make it only open to the player that has the gamepass and not the npcs that dont have it

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 6489429 --Replace this set of numbers with your gamepass id

function onPlayerSpawned(player) 

    local hasPass = false

    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
    end)
-- The script below is for checking whether or not the player has the gamepass.
    if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end

    if hasPass == true then
  game.Workspace.GamepassDoor.Gamepass.CanCollide = false
  game.Workspace.GamepassDoor.Gamepass.Transparency = 1
 end
end 

game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

Players.PlayerAdded:Connect(onPlayerSpawned)
0
If this program is Local, it will only affect you. The VIP door works perfectly fine, except the fact that the NPC is apart of your local render, and is not a Player, meaning no matter what, the Part will remain CanCollide false. You can filter for your Player only via GetPlayerFromCharacter in a Touched event and project failures (teleport back) to prevent the NPC from getting in. Ziffixture 6913 — 4y
0
Try looking into Collision groups, you could give players that have vip access a certain collision group that lets them pass through the vip door kisty1 111 — 4y

Answer this question