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

How to get strength to double each rebirth?

Here is my punch script. Basically i want a new player to join the game and start off with 0 damage which is the (dmg) variable i set it to 25 for testing. And as you play the game you get strength(strength = Plr.leaderstats.strength) and the more strength the more dmg so 1k strength is 1k damage. I also want damage to be based off of rebirths(rb = Plr.leaderstats.rebirths.Value) so 1 rebirth doubles your damage so 1k strength and 1 rebirth is 2k damage and 2 rebirths will be 4x damage and 3 will be 6k damage. But for some reason changing my rebirths doesnt change the damage output and idk why.

local canDoDmg = false
local dmg = 25 
local db = false

local Plr = game.Players.LocalPlayer
local strength = Plr.leaderstats.strength
local rb = Plr.leaderstats.rebirths.Value
local UserInputService = game:GetService("UserInputService")
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6203475027"
local track = Humanoid:LoadAnimation(Anim)

UserInputService.InputBegan:Connect(function(InputObject)
	if InputObject.UserInputType == Enum.UserInputType.MouseButton1 and db == false then 
		track:Play()
		canDoDmg = true
		db = true

		script.Parent.RightHand.Touched:connect(function(hit)
			if hit.Parent.Humanoid and canDoDmg == true then
				local TotalDamage = dmg -- default value with 0 rebirths

				for i = 1, rb do
					TotalDamage *= 2
				end

				hit.Parent.Humanoid:TakeDamage(TotalDamage)
			end
		end)
		delay(1, function()
			canDoDmg = false
			db = false
		end)
		wait(10)
	end
end)






1 answer

✓ Accepted answer

Try this and let me know if it works.

local canDoDmg = false
local dmg = 25 
local db = false

local Plr = game.Players.LocalPlayer
local strength = Plr.leaderstats.strength
local rb = Plr.leaderstats.rebirths
local UserInputService = game:GetService("UserInputService")
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6203475027"
local track = Humanoid:LoadAnimation(Anim)

UserInputService.InputBegan:Connect(function(InputObject)
    if InputObject.UserInputType == Enum.UserInputType.MouseButton1 and db == false then 
        track:Play()
        canDoDmg = true
        db = true

        script.Parent.RightHand.Touched:connect(function(hit)
            if hit.Parent.Humanoid and canDoDmg == true then
                local TotalDamage = dmg -- default value with 0 rebirths

                if rb.Value > 0 then
                    TotalDamage *= rb.Value
                end

                hit.Parent.Humanoid:TakeDamage(TotalDamage)
            end
        end)
        delay(1, function()
            canDoDmg = false
            db = false
        end)
        wait(10)
    end
end)

3 comments

0

ok i tested it and when you gain strength it doesnt increase the damage but when you rebirth it does

0

Thats because dmg is a constant value, you didnt base it off strength.

0

Change line 23 to reflect the strength variable.

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