Need help with accounting for regeneration in tool

  1. I want the tool to subtract the player’s current in-game value by 10

  2. The tool subtracts 10, then 20, then 30, etc.

  3. I have tried clarifying what the in-game value is

I ASSUME THE PROBLEM IS - the code is not accounting for the player’s regeneration of the value
(in a separate script) and subtracting what the code believes the value is

local Tool = script.Parent;

enabled = true
cd = false
local cooldown =  10


function onActivated()
	local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	

	
	if cd == false and player.Chakra.Value >= 10 then

	player.Chakra.Value -= 10
	script.Parent.CoolDown:FireClient(player,cooldown)
	local Character = Tool.Parent
	local blood = game.ReplicatedStorage.Blood:Clone()
	local log = game.ReplicatedStorage.Log:Clone()
	blood.Position = Character.Torso.Position
	blood.Parent  = game.Workspace
	log.Parent = game.Workspace
	log.Position = Character.Torso.Position
	log.Sound:Play()
	cd = true
	Character.HumanoidRootPart.CFrame *= CFrame.new(15, 0, 0)
	wait(1)
		blood:Destroy()
		wait(9)
	log:Destroy()
	cd = false
end

end



script.Parent.Activated:connect(onActivated)
1 Like

solved this a really long time ago, but in case anybody is having trouble with a similar issue, use a server script not a local script for subtraction.

1 Like

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