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

Why does this script not damage any players above eternity 40?

Asked by 7 years ago

I recently made this script, when invoked sends over the player, the npc model or character, and the type of attack it is. Though it does not work on Players, even though the player and the targeted player is higher eternity then 40. It does work with Npcs though. How would i make it so it can damage players have a eternity value of over 40? I tried debugging this before aswell

--Variables
local replicatedstorage = game.ReplicatedStorage
local remoteinstance = replicatedstorage:WaitForChild("RemoteInstance")
local damagefunction = remoteinstance:WaitForChild("DamageFunction")
local enabled = false

--Function for Damaging NPCs + Players

function DamageHumanoid(player, mob, attacktype)
    if attacktype == "Punch" then
    local damage = player.BaseValue:FindFirstChild("Strength").Value * 1.25
    local eternity = player.BaseValue:FindFirstChild("Eternity").Value * 1.5
    local truedamage = damage + 7
    local rounddamage = math.floor(truedamage + 0.5)
    local roundeternity = math.floor(eternity + 0.5)
    local additiondamage = rounddamage + roundeternity
    local humanoid = mob:FindFirstChild("Humanoid")
    humanoid:TakeDamage(additiondamage)
    elseif attacktype == "Kick" then
    local damage = player.BaseValue:FindFirstChild("Strength").Value * 1.25
    local eternity = player.BaseValue:FindFirstChild("Eternity").Value * 1.5
        local truedamage = 12 + damage
        local rounddamage = math.floor(truedamage + 0.5)
        local roundeternity = math.floor(eternity + 0.5)
        local additiondamage = rounddamage + roundeternity
        local humanoid = mob:FindFirstChild("Humanoid")
        humanoid:TakeDamage(additiondamage)                         
end
end

--When invoked, sends the player, the npc or player character and a string value

function damagefunction.OnServerInvoke(rplayer, rmob, rattacktype)
if enabled == false then
if rmob:FindFirstChild("STATSFOLDER") then
enabled = true
DamageHumanoid(rplayer, rmob, rattacktype)
    elseif rmob:FindFirstChild("Health") then
    if rmob:FindFirstChild("CheckHumanoid") and rplayer:FindFirstChild("BaseValue").Eternity.Value >= 40
    and game.Players[rmob.Name].BaseValue:FindFirstChild("Eternity").Value >= 40 then
    enabled = true
    DamageHumanoid(rplayer, rmob, rattacktype)  
    end
    end
    end
    enabled = false
    end

Answer this question