Damage booster issue

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Whenever you press E with a Tool it increases its total damage
  2. What is the issue? Include screenshots / videos if possible!
    The Damage value is being modified and added, but whenever you try to use the weapon and damage something it does the same damage as if the values never changed.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried making remote events and seeing if anything changed with any other values but it stayed the same.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- local script inside the tool
local specialready = true

game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
	if specialready == true then
		if key == "e" then
			specialready = false
			game.ReplicatedStorage.EnableAbility:FireServer(player)
			wait(30)
			game.ReplicatedStorage.DisableAbility:FireServer(player)
		end
	end
end)

-- server script inside serverscriptservice

game.ReplicatedStorage.EnableAbility.OnServerEvent:Connect(function(player)
	if player.Character:FindFirstChild("GoldenBlade") then
		local GoldenBlade = player.Character:FindFirstChild("GoldenBlade")
		GoldenBlade.settingsfldr.DamageMod.Value += 8
	end
end)

game.ReplicatedStorage.DisableAbility.OnServerEvent:Connect(function(player)
	if player.Character:FindFirstChild("GoldenBlade") then
		local GoldenBlade = player.Character:FindFirstChild("GoldenBlade")
		GoldenBlade.settingsfldr.DamageMod.Value -= 8
end)

-- the damage script for the weapon
local Tool = script.Parent
local settingsfolder = script.Parent.settingsfldr

local cooldown = settingsfolder.Cooldown.Value
local PlayersHit = {}
local canswing = true
local candamage = false
local multi = Tool.settingsfldr.DamageMod.Value

local Min = Tool.settingsfldr.MinDamage.Value * multi
local Max = Tool.settingsfldr.MaxDamage.Value * multi

Tool.Activated:Connect(function()

	if canswing == true then
		candamage = true
		canswing = false
		wait(cooldown)
		canswing = true
		candamage = false
	end
end)




Handle.Touched:Connect(function(Hit)

	if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Tool.Parent and not game.Players:FindFirstChild(Hit.Parent.Name) then

		if candamage == true and PlayersHit[Hit.Parent] == nil then

			Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(math.random(Min, Max))

			PlayersHit[Hit.Parent] = true
			wait(1)
			PlayersHit[Hit.Parent] = nil
		end
	end
end)
  • Extra note all the number variable ( e.g MinDamage ) are all stored inside of a folder inside the tool and they are all number values.
1 Like

Changing the value of Tool.settingsfldr.MinDamage or Tool.settingsfldr.MaxDamage won’t change the value of the variable Min and Max.

For example,

IntValue.Value = 3
local value = IntValue.Value
print(value)
-- Prints out 3 

IntValue.Value = 10
print(value)
-- Still prints out 3

When you do IntValue.Value = 3, you’re setting the value of the IntValue object to 3.

Next, you assign the value of IntValue.Value (which is currently 3) to the local variable value. At this point, value contains a copy of the current value of IntValue.Value, which is 3.

When you then update IntValue.Value to 10, you’re changing the value stored in the IntValue object to 10. However, this doesn’t automatically update the value stored in the local variable value.

When you print value after updating IntValue.Value , it still prints out 3 , because the value stored in value was assigned before the change to IntValue.Value occurred.

So, in this example, if you wanted the value to print out 10 which is the new value of IntValue.Value you would have to do

IntValue.Value = 3
local value = IntValue.Value
print(value)
-- Prints out 3 

IntValue.Value = 10
value = IntValue.Value
print(value)
-- Now prints out 10

This way, you update the value variable with the new value of IntValue.Value , reflecting the updated value after changing IntValue.Value to 10 .

And now if you want to make your code work the way you expect, right before Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(math.random(Min, Max)), you will have to reassign the value of Min and Max to Tool.settingsfldr.MinDamage.Value * multi and Tool.settingsfldr.MaxDamage.Value * multi

1 Like

Wow that actually worked. Thank you so much!

1 Like

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