Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Health By GamePass?

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

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)

4 comments

0

Well yes, you see...I scripted that part already. It is the executing function part that is not working...

0

There, sorry for not providing the attempt, I added it.

0

This should work.

0

It is still healing even if I don't have the game pass.

This discussion is preserved as it was. New answers, comments, and votes are closed.