i need it for my roblox minigame
How do I make a vip that when they don't have the gamepass it kills them instantly?
2 answers
https://wiki.roblox.com/index.php?title=API:Class/GamePassService/PlayerHasPass
https://wiki.roblox.com/index.php?title=API:Class/Humanoid/Health
Set player's health to 0 if this returns false.
You will want to check if the player has the gamepass using gamepass service https://wiki.roblox.com/index.php?title=API:Class/GamePassService/PlayerHasPass
You will want to check if they touched the door using the .Touched event which is fired when a basepart is touched. https://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched
And to get the player from the character we will use https://wiki.roblox.com/index.php?title=API:Class/Players/GetPlayerFromCharacter
Also to kill the player we will use :BreakJoints() since it kills the player. I prefer :BreakJoints() over setting the health to zero since it takes less referencing.
Alright lets get coding.
(In this case we will put the script inside the door instance)
local gamepassService = game:GetService("GamePassService")
local players = game:GetService("Players")
local door = script.Parent
local gamepassID = 123456789
local canTouch = true
local function gamepassCheck(player)
if not gamepassService:PlayerHasPass(player, gamepassID) then
player.Character:BreakJoints()
end
end
local function doorTouched(hit)
if canTouch then
canTouch = false
local player = players:GetPlayerFromCharacter(hit.Parent) or players:GetPlayerFromCharacter(hit.Parent.Parent)
if player then
gamepassCheck(player)
end
canTouch = true
end
end
door.Touched:Connect(doorTouched)
Make sure to change the gamepass to the ID you are using. (Tell me if the script has any problems.)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Bold