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

How do I make a vip that when they don't have the gamepass it kills them instantly?

Asked by
Falzoon -2
5 years ago

i need it for my roblox minigame

0
Bold magicguy78942 238 — 5y

2 answers

Log in to vote
1
Answered by
waifuSZN 123
5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

Answer this question