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

Health By GamePass?

Asked by 10 years ago

I need a script where if you have DON'T have a game pass then it removes the "Health" script within your character that you get every time you spawn (game.Workspace.CHARACTERSNAME.Health). at this script does is allows your character to regenerate lost health over time. However, if they DO have the game pass then it does NOT remove this script.

How do I do this?

My Attempt:

gp = 162631986
Game.Players.PlayerAdded:connect(function(Player)
if Game:GetService("GamePassService"):PlayerHasPass(Player, gp) then
    end
    else game.Workspace.Player.Health:remove()
end

Attempt Two:

gp = 162631986
Game.Players.PlayerAdded:connect(function(Player)
    if Game:GetService("GamePassService"):PlayerHasPass(Player, gp) then
    return
    else game.Workspace.Player.Health:remove()
    end
end)

Attempt Three:

gp = 162631986
wait(1)
Game.Players.PlayerAdded:connect(function(Player)
    if Game:GetService("GamePassService"):PlayerHasPass(Player, gp) then
    return end
    p = Player.Name     
    game.Workspace[p].Health:remove()
end)

(Sorry, first time here. Didn't know the script attempt was required)

1 answer

Log in to vote
0
Answered by
TofuBytes 500 Moderation Voter
10 years ago

Good tries. Here's the fix to your problem.

local gp = 162631986

game.Players.PlayerAdded:connect(function(player)
        if Game:GetService("GamePassService"):PlayerHasPass(player, gp) then
            print("Game Pass Found") --If the user has game pass we just print they have it.
        else
            print("Game Pass Not Found -- Health Destroyed") 
            char:WaitForChild("Health"):Destroy() --If they don't, we wait for the 'Health' script and then destroy it.
        end
end)

0
Well yes, you see...I scripted that part already. It is the executing function part that is not working... PropheticExtinction 75 — 10y
0
There, sorry for not providing the attempt, I added it. PropheticExtinction 75 — 10y
0
This should work. TofuBytes 500 — 10y
0
It is still healing even if I don't have the game pass. PropheticExtinction 75 — 10y
Ad

Answer this question