God coil for gamepass

Hello everyone, so today I was making gamepasses and I wanted to have a god coil. So when the player buys the coil, the person can never die. I am not really sure how to make a coil that can have that because, when you touch a part, your health goes to 0 no matter what. Does anyone know how to make one that makes you never die? Here is the death script, and you can see what I am talking about.

function DeathTouch(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		hit.Parent.Humanoid.Health = 0
	end
end

for _,v in pairs(workspace:GetChildren()) do
	if v.Name == 'killme' then
		v.Touched:Connect(function(hit)
			DeathTouch(hit)
		end)
	end
end

workspace.ChildAdded:Connect(function(Child)
	if Child.Name == 'killme' then
		Child.Touched:Connect(function(hit)
			DeathTouch(hit)
		end)
	end
end)
2 Likes

Instead of having the kill brick set the health to 0 just remove 100 health like this

function DeathTouch(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 100
	end
end

And just make the god coil set the MaxHealth & Health to 9e9 and if that is not possible do math.huge

2 Likes

You can replace the killbrick damage with Humanoid:TakeDamage(amount of damage).
Then you can add a starterCharacterScript so that as long as they have the coil, they’ll spawn in with an infinite invisible forcefield.

Just a note: if the game this is for is a game based on fighting, this gamepass will make your players think it’s Pay To Win.

3 Likes

If i were you, I would create a new value called “god coil” when the player joins, check if that player has the certain value(basically if they have the gamepass), and when you do the touched event, you can just go like this:

function DeathTouch(hit)
    local char = hit.Parent
    local player = game.Players:FindFirstChild(char.Name)
    if hit.Parent:FindFirstChild('Humanoid') and player.Folder.HasGodCoil.Value == false then
	    hit.Parent.Humanoid.Health = 0
    else
        print("Has god mode!")
    end
end

It’s not lol, It’s an obby

30000

so something like this?

health = 9e9
active = false
script.Parent.Equipped:connect(function()
	active = true
end)
script.Parent.Unequipped:connect(function()
	active = false
end)
while wait(0.1) do
	if active then
		script.Parent.Parent.Humanoid.Health = script.Parent.Parent.Humanoid.MaxHealth + health
	end
end

I think I did that right, just let me know if I did that wrong. Thanks :)))

Yeahhh, that didn’t work because I died automatically. I changed the kill part to -100 idky it’s still doing this.

function DeathTouch(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health -100
	end
end

for _,v in pairs(workspace:GetChildren()) do
	if v.Name == 'killme' then
		v.Touched:Connect(function(hit)
			DeathTouch(hit)
		end)
	end
end

workspace.ChildAdded:Connect(function(Child)
	if Child.Name == 'killme' then
		Child.Touched:Connect(function(hit)
			DeathTouch(hit)
		end)
	end
end)

What type of value would it be? A bool value?

Also, where did you get the hasgodcoil? what does it store in it?

I also need to know where you are storing this stuff, I am pretty new to scripting, so I need you to be more clear with me.

The best solution, as I said, is to add an infinite forcefield to the player when they spawn in.

--put in StarterPlayer > StarterCharacterScripts as a ServerScript
local character = script.parent.parent.Character
local forceField = instance.New("forceField")
forceField.Parent = character
forceField.Visible = false
forceField.Active = true

And replace killbrick scripts with this:

local killbrick = script.Parent
local function onTouch (otherPart)
        local humanoid = otherPart.Parent:FindFirstChildWhichIsA("Humanoid")
        humanoid:TakeDamage(100)
end
killbrick.Touched:Connect(onTouch)

Still doesnt’ work… this is my script

local killbrick = script.Parent

local function onTouch (otherPart)
	local humanoid = otherPart.Parent:FindFirstChildWhichIsA("Humanoid")
	humanoid:TakeDamage(100)
end
killbrick.Touched:Connect(onTouch())

not sure what else I can do at this point.

nvm I got it, thanks :)) have a good day.

1 Like