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

Value not updating damage?

Asked by 4 years ago

I'm making a stat system, and in the script below, I have an attack that damage multiplies by the stats value. During testing, however, it only multiplied it by the default amount (1). In other words, when I updated my stats, it didn't multiply by the updated stat. It works, as I set it to a higher number and it multiplied, but it wouldn't update if the value was updated.

game.ReplicatedStorage.Events.Skill1.OnServerEvent:Connect(function(player, mousePos)
    local effects = game.ReplicatedStorage.Effects
    local fireBall = effects.MagicSkill:Clone()
    local explosion = effects.Explosion:Clone()
    local character = player.Character
    local StrVal = player.StatFolder.Str.Value
    --Fireball--
    fireBall.Position = character.RightHand.Position
    fireBall.Parent = workspace

    --Weld--
    local weld = Instance.new("WeldConstraint", fireBall)
    weld.Part0 = fireBall
    weld.Part1 = character.RightHand
    wait(0.1)
    weld:Destroy()

    local velocity = Instance.new("BodyVelocity", fireBall)
    velocity.Velocity = CFrame.new(fireBall.Position, mousePos).LookVector * 100

    --Explosion--
    fireBall.Touched:Connect(function(hit)
        if hit:IsDescendantOf(character)or hit:FindFirstChild("ParticleEmitter") then return end
        explosion.Position = fireBall.Position
        fireBall:Destroy()
        explosion.Parent = workspace

        if hit.Parent:FindFirstChild("Humanoid") then
            hit.Parent:FindFirstChild("Humanoid"):TakeDamage(30 * StrVal) --Where I tried to multiply it

        end
        wait(5)
        explosion:Destroy() 
    end)
end)

0
try updating the strval every time it does a takedamage event (strval = player.StatFolder.Str.Value) RAFA1608 543 — 4y
0
alr, ill try it right now. hihowareya115 53 — 4y
0
still doing damage, but its not multiplying still. hihowareya115 53 — 4y

Answer this question