Need help making a rebirth function

I skidded a rebirth script but idk how to really use it I tried doing this
if game.Players.localplayer.leaderstats.Rebirths.Value == 1 then do
db = true
animtrack1:Play()
plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value + 2
wait(_M.cooldown)
db = false
end

but it didnt work so here is the whole script

local _M = require(script.Parent.Settings)
local db = false
local tool = script.Parent
repeat wait() until tool.Parent.Parent:IsA("Player")
local plr = tool.Parent.Parent
local character = plr.Character

local anim1 = tool:WaitForChild("LiftAnim")
local animtrack1 = character.Humanoid:LoadAnimation(anim1)

local anim2 = tool:WaitForChild("IdleAnim")
local animtrack2 = character.Humanoid:LoadAnimation(anim2)

tool.Activated:Connect(function()
	if not db then
		db = true
		animtrack1:Play()
		plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value + _M.strengthPerClick
		wait(_M.cooldown)
		db = false
	
	end
	
	
end)


tool.Equipped:Connect(function()
	character.Humanoid.WalkSpeed = 0
	animtrack2:Play()
end)

tool.Unequipped:Connect(function()
	character.Humanoid.WalkSpeed = 16
	animtrack2:Stop()
end)

module script

local module = {
	
			strengthPerClick = 1,
			cooldown = 1,
			RequiredStrength = 0

}

return module
1 Like

You can check the players rebirth value, and if it’s greater than 1 or something like that you can multiply the strength return by rebirths.Value + 1

1 Like

Wouldn’t that be the same thing that I have done?

1 Like

Kind of, but you are doing it on the client, you’re only checking if they’re at 1 rebirth, and from what I can see you only check once.

1 Like

On my first try when I modified the script it stopped working like gaining strength

1 Like

Was there any errors?

This text will be blurred

1 Like

No this is also not working

ok wait I see I am dumb lol

2 Likes

To multiply, you do not to 2 x 3, instead you do 2 * 3.

1 Like

In the line where you wrote plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value x 2, if you’re trying to multiply, use the * symbol. Also for the line game.Players.localplayer.leaderstats.Rebirths.Value >= 1 then do, in Lua, you write if (condition) then (there’s no need for the do) so you could rewrite the line as if plr.leaderstats.Rebirths.Value >= 1 then. Just make sure you already defined plr.

1 Like

Yeah i know I fixed it but its still not working

1 Like

but will this brake my code or is it just some extra

1 Like

I’m pretty sure you are also missing an end, add an end) after the last end and see if the code works. Everything looks fine to me

1 Like

Yeah I have also noticed the ) and fixed it but it didnt work

1 Like

So far this is my code but it won’t work

 local _M = require(script.Parent.Settings)
    local db = false
    local tool = script.Parent
    repeat wait() until tool.Parent.Parent:IsA("Player")
    local plr = tool.Parent.Parent
    local character = plr.Character

local anim1 = tool:WaitForChild("LiftAnim")
local animtrack1 = character.Humanoid:LoadAnimation(anim1)

local anim2 = tool:WaitForChild("IdleAnim")
local animtrack2 = character.Humanoid:LoadAnimation(anim2)

tool.Activated:Connect(function()
	if not db then
	
		if plr.leaderstats.Rebirths.Value >= 1 then
			db = true
			animtrack1:Play()
			plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value *2
			wait(_M.cooldown)
			db = false
		end


	
end
		

tool.Equipped:Connect(function()
	character.Humanoid.WalkSpeed = 0
	animtrack2:Play()
end)

tool.Unequipped:Connect(function()
	character.Humanoid.WalkSpeed = 16
	animtrack2:Stop()
end)
1 Like

Maybe the leaderstats value is 0? You are multiplying the leaderstats value by 2, and 0x2 = 0. Try changing it to 2 or something to see if it is changing the value.

1 Like

Not working still
game.Players.ScriptFiIe.leaderstats.Rebirths.Value = 1

1 Like

Dang, idk then. Everything looks fine to me, I don’t see why it would be erroring. Hopefully someone else knows, sorry :frowning:

1 Like

Try this:

local _M = require(script.Parent.Settings)
local db = false
local tool = script.Parent
repeat wait() until tool.Parent.Parent:IsA("Player")
local plr = tool.Parent.Parent
local character = plr.Character

local anim1 = tool:WaitForChild("LiftAnim")
local animtrack1 = character.Humanoid:LoadAnimation(anim1)

local anim2 = tool:WaitForChild("IdleAnim")
local animtrack2 = character.Humanoid:LoadAnimation(anim2)

tool.Activated:Connect(function()
	if not db then
		if plr.leaderstats.Rebirths.Value >= 1 then
			db = true
			animtrack1:Play()
			plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value *2
			wait(_M.cooldown)
			db = false
		end
	end
end)

tool.Equipped:Connect(function()
	character.Humanoid.WalkSpeed = 0
	animtrack2:Play()
end)

tool.Unequipped:Connect(function()
	character.Humanoid.WalkSpeed = 16
	animtrack2:Stop()
end)
1 Like

It is not working and no errors in the output

1 Like

I only added some print commands, so tell me what’s in the output this time.

local _M = require(script.Parent.Settings)
local db = false
local tool = script.Parent
repeat wait() until tool.Parent.Parent:IsA("Player")
local plr = tool.Parent.Parent
local character = plr.Character

local anim1 = tool:WaitForChild("LiftAnim")
local animtrack1 = character.Humanoid:LoadAnimation(anim1)

local anim2 = tool:WaitForChild("IdleAnim")
local animtrack2 = character.Humanoid:LoadAnimation(anim2)

print("Loaded")

tool.Activated:Connect(function()
	print("Activated")
	if not db then
		print("Debounce False")
		if plr.leaderstats.Rebirths.Value >= 1 then
			print("Rebirthed")
			db = true
			animtrack1:Play()
			plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value * 2
			wait(_M.cooldown)
			db = false
		end
	end
end)

tool.Equipped:Connect(function()
	character.Humanoid.WalkSpeed = 0
	animtrack2:Play()
end)

tool.Unequipped:Connect(function()
	character.Humanoid.WalkSpeed = 16
	animtrack2:Stop()
end)
1 Like