How do i make it so when a player touches a part it kicks them but when they own the gamepass it does not kick them also the gamepass id is (27455846) Also should it be a local script or script?
✓ ANSWER ACCEPTED
How to make it so it kicks a player when they touch a part?
1 answer
✓ Accepted answer
--Server Script inside the part
local gpid=27455846
local mps,tab=game:GetService"MarketplaceService",{}
mps.PromptGamePassPurchaseFinished:Connect(function(player,id,wasPurchased)
if wasPurchased and id==gpid then
tab[player.Name]=true
end
end)
local part,debounce,main=script.Parent,false,function(player)
if tab[player.Name]then return end
if mps:UserOwnsGamePassAsync(player.UserId,gpid)then
tab[player.Name]=true
else
player:Kick()
end;end
local Players=game.Players
part.Touched:Connect(function(v)
if debounce then return end
debounce=true
local player=Players:GetPlayerFromCharacter(v.Parent)
if player then pcall(main,player)end
wait(.5)
debounce=false
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
