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

Why does this VIP door script not work? Because I have no idea why.

So... I'm making a game with a vip gamepass. This script apparently doesn't affect people that don't have the gamepass. No idea why.

script.Parent.Touched:connect(function(hit,player)
local passId = 724007686

local function isAuthenticated(player)
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end

local function Start(player)
    print(player.Name .. " has bought the game pass with id " .. passId)
end

    if isAuthenticated(player) then
        return
    else
		hit.Parent.Humanoid.Health = 0
	end

end)

Thanks.

1 comment

0

Every time a the touched event fires it connects new function to the PlayerAdded event??

1 answer

✓ Accepted answer

The touched event does not return the player as a second parameter. you should do this to check if the object that hit it is a character

script.Parent.Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)

	if player then
		local passId = 724007686

 

		local function isAuthenticated(player)
		
			return game:GetService("GamePassService"):PlayerHasPass(player, passId)
		
		end

 

		local function Start(player)
		
		    print(player.Name .. " has bought the game pass with id " .. passId)
		
		end
 
		if isAuthenticated(player) then
		
		return
		
		else
		
		hit.Parent.Humanoid.Health = 0
		
		end
	end
end)

1 comment

0

sorry about the tabbing problems the spacing is weird for this comment format

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