Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

VIP Door script?

I'm attempting to make a script for a VIP door if someone owns a gamepass to go through it, but they won't die, so far I have: Id = 154872414 Door = Script.Parent Game: GetService ('Players') Not sure what to do next.. I think I would do a code for the script to search for a humanoid and if they humanoid has the pass or not, and if so, opens the door when they touch it (Not sure how to code that..)

1 answer

Humanoid is a part of the character, what you're looking for is whether the player connected to the character has the pass.

ID = 154872414
Door = script.Parent
Door.Touched:connect(function(hit)
	if hit.Parent.Humanoid then -- 1
		Player = game.Players:GetPlayerFromCharacter(hit.Parent) -- 2
		if game:GetService("GamePassService"):PlayerHasPass(Player, ID) then -- 3
			script.Parent.CanCollide = false -- 4
			script.Parent.Transparency = 0.5
			wait(2)
			script.Parent.CanCollide = true
			script.Parent.Transparency = 0
		end
	end
end)

--1 Checks whether the part that touched the door is human or not. However, there is the issue with hats.. the event disconnects if the part was a hat.
--2 If the part is part of a human, it gets the player from the part's parent, which is the character model.
--3 If the player has the pass..
--4 Then the player can walk through the door. I'd suggest making the character teleport, though, if you don't want others mooching of the player with the pass

2 comments

0

It didn't work, I don't know why it seems to be fine, but it won't allow me to go through the door.

0

xeron750 did you change the id for your gamepass

This discussion is preserved as it was. New answers, comments, and votes are closed.