GamePass Increases the damage help

Hello everyone am trying to make a gamepass where when the player owns it the damage is 2X to the enemy So how can i do it

You can use :UserOwnsGamePassAsync() to check if a user owns a specific gamepass, and include a multiplier counter should the player own the gamepass. Here’s a brief example on how you can implement this:

local marketplace = game:GetService("MarketplaceService")
local multiplier = 1

if marketplace:UserOwnsGamePassAsync(userId, gamepassId) then
   multiplier += 1
elseif ...
   multiplier +=1
end

--Other code here...

local damage = 10 * multiplier --Assuming that 10HP is your base damage

-- Other code here...
1 Like

Yeah i used some of your script but there is a problem

game.ReplicatedStorage.GamePassOwned.OnServerEvent:Connect(function(Character , Damage )
	print(Character.Name.." Owns the Game Pass")
	local DV = Character:WaitForChild("HitBox"):WaitForChild("Value")
	DV.Value = 4
	print(DV.Value)
	print("Succesfully Damage is Doubled")
end)
	

i mad a local script that fires the remote function when player owns the gamepass but
it writes to me in the output

Infinite yield possible on ‘Players.wolfmanOs:WaitForChild(“HitBox”)’

Are you sure this HitBox value even exists? Or does the script still work even with this error (because that usually means that the script originally just didn’t manage to find the value in a fixed period of time and sent out that warning)?

Hitbox doesn’t exist, I am pretty sure. You can use HumanoidRootPart which is the equivalent of the hitbox.

game.ReplicatedStorage.GamePassOwned.OnServerEvent:Connect(function(Character , Damage )
	print(Character.Name.." Owns the Game Pass")
	local DV = Character:WaitForChild("HumanoidRootPart"):WaitForChild("Value")
	DV.Value = 4
	print(DV.Value)
	print("Successfully doubled the damage.")
end)
1 Like

Yes it exist and i can’t make it hrp cuz it is meant to damage the player

1 Like

Can you please show your damage script?

1 Like

Sorry for the late reply and also the gamepass made me alot of issues

local Hit = game.ReplicatedStorage.Hit
local CanDamage = false
local canbetouched = false
local Blocking2 = false
local Functione1 = true
local Functionne2 = true
local Damage = 2.5
local Hit = game.ReplicatedStorage.Hit
local CanDamage = false
local canbetouched = false
local Blocking2 = false
local Functione1 = true
local Functionne2 = true
local Damage = 2.5


game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character1)
		local DV = Character1.Value
		game.ReplicatedStorage.GamePassOwned.OnServerEvent:Connect(function(Character  )
			print(Character.Name.." Owns the Game Pass")
			if DV.Parent.Name == Character.Name then
				Character1:FindFirstChild("Value").Value = 4
				print(DV.Value)
				print("Succesfully Damage is Doubled")
			else
				print("PlayerLeft or No gamepass")
			end


		end)
		local HRP = Character1:WaitForChild("HumanoidRootPart")
		local Humanoid = Character1:WaitForChild("Humanoid")




		HRP.Touched:Connect(function(H)
			if H.Name == "HitBox" and Blocking2 == false  then

				Humanoid:TakeDamage(DV.Value)
				print(DV.Value)
				HRP:FindFirstChild("Punch"):Play()

			end
		end)
		game.ReplicatedStorage.Blocking.OnServerEvent:Connect(function(Player , Blocking )
			Blocking = true
			Blocking2 = true
			Functione1 = false
			Functionne2 = true
			HRP.Touched:Connect(function(H)
				if H.Name == "HitBox" and Blocking == true and Functionne2 == true  then
					Humanoid:TakeDamage(DV.Value)
					return Blocking2

				end
			end)
		end)

		game.ReplicatedStorage.Unblock.OnServerEvent:Connect(function(Player , Blocking )
			Functione1 = true
			Functionne2 = false
			HRP.Touched:Connect(function(H)
				if H.Name == "HitBox" and Blocking == false and  Functione1 == true then
					Humanoid:TakeDamage(DV.Value)
					HRP:FindFirstChild("Punch"):Play()
					return Blocking2

				end
			end)
		end)



	end)
end)




Hit.OnServerEvent:Connect(function(Player , Hit_Count , Character)
	canbetouched = true

	CanDamage = true
	local LeftArm =Character:WaitForChild("Left Arm")
	local RightArm =Character:WaitForChild("Right Arm")

local Swish = Character:WaitForChild("HumanoidRootPart"):WaitForChild("Swish")
	local A = 	Character:WaitForChild("HitBox"):FindFirstChild("HitBox")

	print(Player.Name , Hit_Count)
	if Hit_Count == 0 and canbetouched == true then
		canbetouched = false
		Swish:Play()
		A.CanTouch = true
		wait(0.2)
		A.CanTouch = false
	elseif Hit_Count == 1 then
		Swish:Play()
		canbetouched = false
		A.CanTouch = true
		wait(0.2)
		A.CanTouch = false
	elseif Hit_Count == 2 then
		Swish:Play()
		canbetouched = false
		A.CanTouch = true
		wait(0.2)
		A.CanTouch = false
	
	
	end
	
end)
game.ReplicatedStorage.Kick.OnServerEvent:Connect(function(Player , CanDamage , PlayerD)
	local Char = Player.Character or Player.CharacterAdded:Wait()
	local HK = Char:WaitForChild("HitBox[Kick]"):WaitForChild("HitBoxKick")
	HK.CanTouch = true
	wait(0.2)
	HK.CanTouch = false
	HK.Parent.Sound:Play()
	end)





The player cannot damage anymore and no errors

Don’t assume the client won’t lie to you. Use MarketplaceService:UserOwnsGamepassAync() on the server. Imagine if an exploiter just fires that to your server and they get the gamepass for free.

try this:

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local gamepassDoubleDmgID = 0 -- replace with yours

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, pass, purchased)
	if purchased == false then
		return
	end
	if pass == gamepassDoubleDmgID then
		player:SetAttribute("OwnsDoubleDamage", true)
	end
end)

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character1)
		local dmg = 2

		local HRP = Character1:WaitForChild("HumanoidRootPart")
		local Humanoid = Character1:WaitForChild("Humanoid")

		if MarketplaceService:UserOwnsGamePassAsync(Player, gamepassDoubleDmgID) then
			Player:SetAttribute("OwnsDoubleDamage", true)
		end


		HRP.Touched:Connect(function(H)
			if H.Name == "HitBox" and Blocking2 == false  then

				Humanoid:TakeDamage(DV.Value)
				print(DV.Value)
				HRP:FindFirstChild("Punch"):Play()

			end
		end)
		game.ReplicatedStorage.Blocking.OnServerEvent:Connect(function(Player , Blocking )
			Blocking = true
			Blocking2 = true
			Functione1 = false
			Functionne2 = true
			HRP.Touched:Connect(function(H)
				if H.Name == "HitBox" and Blocking == true and Functionne2 == true  then
					Humanoid:TakeDamage(dmg * (Player:GetAttribute("OwnsDoubleDamage") and 2 or 1))
					return Blocking2

				end
			end)
		end)

		game.ReplicatedStorage.Unblock.OnServerEvent:Connect(function(Player , Blocking )
			Functione1 = true
			Functionne2 = false
			HRP.Touched:Connect(function(H)
				if H.Name == "HitBox" and Blocking == false and  Functione1 == true then
					Humanoid:TakeDamage(dmg * (Player:GetAttribute("OwnsDoubleDamage") and 2 or 1))
					HRP:FindFirstChild("Punch"):Play()
					return Blocking2

				end
			end)
		end)
	end)
end)

1 Like

There is an error says “Unable to cast Instance to int64”

try this:

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local gamepassDoubleDmgID = 0 -- replace with yours

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, pass, purchased)
	if purchased == false then
		return
	end
	if pass == gamepassDoubleDmgID then
		player:SetAttribute("OwnsDoubleDamage", true)
	end
end)

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character1)
		local dmg = 2

		local HRP = Character1:WaitForChild("HumanoidRootPart")
		local Humanoid = Character1:WaitForChild("Humanoid")

		if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassDoubleDmgID) then
			Player:SetAttribute("OwnsDoubleDamage", true)
		end


		HRP.Touched:Connect(function(H)
			if H.Name == "HitBox" and Blocking2 == false  then

				Humanoid:TakeDamage(DV.Value)
				print(DV.Value)
				HRP:FindFirstChild("Punch"):Play()

			end
		end)
		game.ReplicatedStorage.Blocking.OnServerEvent:Connect(function(Player , Blocking )
			Blocking = true
			Blocking2 = true
			Functione1 = false
			Functionne2 = true
			HRP.Touched:Connect(function(H)
				if H.Name == "HitBox" and Blocking == true and Functionne2 == true  then
					Humanoid:TakeDamage(dmg * (Player:GetAttribute("OwnsDoubleDamage") and 2 or 1))
					return Blocking2

				end
			end)
		end)

		game.ReplicatedStorage.Unblock.OnServerEvent:Connect(function(Player , Blocking )
			Functione1 = true
			Functionne2 = false
			HRP.Touched:Connect(function(H)
				if H.Name == "HitBox" and Blocking == false and  Functione1 == true then
					Humanoid:TakeDamage(dmg * (Player:GetAttribute("OwnsDoubleDamage") and 2 or 1))
					HRP:FindFirstChild("Punch"):Play()
					return Blocking2

				end
			end)
		end)
	end)
end)

			end)
		end)
	end)
end)
1 Like

There is no errors but the player Doesn’t take damage. Am sorry for asking alot.

That’s a separate problem. I already solved the topic of how to make a game pass increase the damage. It’s probably a problem with your blocking system.

Please mark me as the solution for the gamepass topic and create a new topic for your separate problem with blocking.

Oh sorry i went Afk trying to solve the issue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.