0

# how to add a multiplier to Humanoid:TakeDamage?

hello again scripting helpers, i have no clue how to make add a multiplier to humanoid:takedamage.

btw the multiplier is a NumberValue thats in the player model

the line i wanna add the multiplier to

        humanoid:TakeDamage(46)


hole script

local tool = script.Parent

local canDamage = false

local Cooldown = false

stronkness = script.Parent.Parent.Strength.Value

local WaitTime: number = .5 --cool down

local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

if not humanoid then return end

if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(46)
tool.Handle.HitSound.TimePosition = 0
tool.Handle.HitSound.Playing = true
else
return
end

canDamage = false
end

local function slash()
if Cooldown then return end
Cooldown = true

local str = Instance.new("StringValue")

str.Name = "e" --idk why i made it e, i just edited the script that i used for an old game
str.Value = "Slash"
str.Parent = tool

canDamage = true

wait(WaitTime)

Cooldown = false
end

local function swingsound()
wait(.3) -- time untill swing sound plays
tool.Handle.SwingSound.TimePosition = 0
tool.Handle.SwingSound.Playing = true
end

tool.Activated:Connect(swingsound)
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)


0
for clarification: i just need a way to make the multiplier work, i dont need help making the multiplier. also i want the multiplier to be the value of a NumberValue thats located in the model of the player. i just need the add the multiplier to the humanoid:TakeDamage(46) line steel_apples 56 — 3d

0
Edited 3 days ago

So, if I understand you correctly, you want to multiply the damage with the value of the NumberValue.

Fixed Script

local tool = script.Parent

local canDamage = false

local Cooldown = false

stronkness = script.Parent.Parent.Strength.Value

local WaitTime: number = .5 --cool down

local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
local client = game:GetService("Players"):GetPlayerFromCharacter(otherPart)
local num = client:FindFirstChildWhichIsA("NumberValue")

if humanoid.Parent ~= tool.Parent and canDamage then
local damage = 46 * num.Value
humanoid:TakeDamage(damage)
tool.Handle.HitSound.TimePosition = 0
tool.Handle.HitSound.Playing = true
end

canDamage = false
end

local function slash()
if Cooldown then return end
Cooldown = true

local str = Instance.new("StringValue")

str.Name = "e" --idk why i made it e, i just edited the script that i used for an old game
str.Value = "Slash"
str.Parent = tool

canDamage = true

wait(WaitTime)

Cooldown = false
end

local function swingsound()
wait(.3) -- time untill swing sound plays
tool.Handle.SwingSound.TimePosition = 0
tool.Handle.SwingSound.Playing = true
end

tool.Activated:Connect(swingsound)
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)

0
it doesnt work, i think i know why, when i try putting anything in the brackets in the humanoid:TakeDamage(46) line it outright breaks the script steel_apples 56 — 3d
0
sorry if you got a bunch of notifications rn, the comment desided to post like, 8 times steel_apples 56 — 3d
0
@steel_apples I re-edited my post give it try. MarkedTomato 620 — 3d