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...
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)
Yes it exist and i canât make it hrp cuz it is meant to damage the player
Can you please show your damage script?
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)
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)
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.