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.
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)