Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

A script that damages a humanoid. Increases damage based on each level, not working?

Asked by 7 years ago

So in this script (located in server script service) is supposed to increase your damage based on each level. The damage works, but the damage value doesn't increase.

PROBLEM: Damage Value does not increase on each level.

Someone help ?

This is FE.

local ServerStorage = game:GetService('ServerStorage')
local strength = ServerStorage.Values:FindFirstChild('Strength').Value

script.Parent.Touched:Connect(function(hit)
    local DmgValues = {script.Dmg.Value, script.DmgCritical.Value, script.Dmg2.Value, script.Dmg3.Value, script.DmgCritical2.Value}
    local char = hit.Parent
    local hum = char:FindFirstChild("Humanoid")
    local chance = math.random(1, #DmgValues)

    if strength == strength*1 then
        script.Dmg.Value = script.Dmg.Value + 1
        script.DmgCritical.Value = script.Dmg.Value + 2
        script.Dmg2.Value = script.Dmg.Value + 1
        script.DmgCritical2.Value = script.Dmg.Value + 2
        script.Dmg3.Value = script.Dmg.Value + 1
    end
        if hum and char.Name ~= script.Parent.Parent.Name then
        hum.Health = hum.Health - DmgValues[chance]
        script.Disabled = true
        wait(0.5)
        script.Disabled = false
    end
    end)


0
I dont get what your trying to do in your code. Strength == strength * 1? thats always going to be true. How much do you want the damage to raise per level. User#17125 0 — 7y
0
strength is actually the name of the level Amputea 2 — 7y
0
if you say script.Disabled = true it stops and wont be able to become false again unless done by another script that is why it wont work. LastApollo 76 — 7y
0
LMAO ur making weight lifting simulator 3 Lolamtic 63 — 7y
0
no lol im making a fighting anime game Amputea 2 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Try this:

local CanTouch = true


local ServerStorage = game:GetService('ServerStorage')
local strength = ServerStorage.Values:FindFirstChild('Strength').Value

script.Parent.Touched:Connect(function(hit)
if CanTouch == true then
    local DmgValues = {script.Dmg.Value, script.DmgCritical.Value, script.Dmg2.Value, script.Dmg3.Value, script.DmgCritical2.Value}
    local char = hit.Parent
    local hum = char:FindFirstChild("Humanoid")
    local chance = math.random(1, #DmgValues)

    if strength == strength*1 then
        script.Dmg.Value = script.Dmg.Value + 1
        script.DmgCritical.Value = script.Dmg.Value + 2
        script.Dmg2.Value = script.Dmg.Value + 1
        script.DmgCritical2.Value = script.Dmg.Value + 2
        script.Dmg3.Value = script.Dmg.Value + 1
    end
        if hum and char.Name ~= script.Parent.Parent.Name then
        hum.Health = hum.Health - DmgValues[chance]
CanTouch = false
wait(.5)
CanTouch = true
    end
else 
wait(.5)
CanTouch = true
end
    end)


I just added a variable

0
the increasing part doesnt work but the damage is still working @greatneil80 Amputea 2 — 7y
Ad

Answer this question