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

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

Asked by 7 years ago
Edited 7 years ago

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.

0
Every time a the touched event fires it connects new function to the PlayerAdded event?? User#5423 17 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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)

0
sorry about the tabbing problems the spacing is weird for this comment format QuantumToast 261 — 7y
Ad

Answer this question