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

How can I make it to where a kill brick won't kill you if you have a certain gamepass?

Asked by 4 years ago

I'm new to scripting and I'm currently making an obby. I've been trying to modify my kill brick script to where you won't die from it if you have a certain gamepass, but I can't figure it out.

Here's the script for the kill brick.

function onTouched(Obj)
    local h = Obj.Parent:FindFirstChild("Humanoid")
    if h then
        h.Health = 0
    end
end

script.Parent.Touched:Connect(onTouched)

1 answer

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

You need to add a script into ServerScriptService here is the code:

local id = (your gamepass Id with no parentheses )

game:GetService(¨MarketplaceService¨).PromptGamePassPurchaseFinished:Connect(functon(plr,ido,purchased)
if purchased and id == ido then
game.Workspace.Killpart.Script.Disabled = true
end
end)

game.Players.PlayerAdded:Connect(function(plr)
if game:GetService(¨MarketplaceService¨)UserOwnsGamePassAsync(plr.UserId.id) then
game.Workspace.Killpart.Script.Disabled = true
end
end)

Oh btw make sure the script in the kill part matches the name of script or you can change the server script thing to match the kill part script

0
also the script in the kill part doesnt matter D0CTOR_CHIL 21 — 4y
0
It works, but only on one kill brick. I need the script to work on all kill bricks. Protigous 20 — 4y
Ad

Answer this question