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

I'm making a Ki blast script but it doesn't damage, what's happening?

Asked by
caipira 29
6 years ago

I want to do the damage from my ki blast based on enemie defense, i did almost the same thing to do a punch and it's working, but when i put the script into the ki blast, it just ignore the condition to check the enemie's defense, sorry if it's a long script:

local player = game.Players.LocalPlayer
local name = player.Name
local candamage = true


local stats = game.ReplicatedStorage:WaitForChild("stats"..name)
local power = stats:WaitForChild("power")
local ki = stats:WaitForChild("ki")
local defense = stats:WaitForChild("defense")
local kidmg = stats:WaitForChild("kidamage")
local chatting = false
local energy = stats:WaitForChild("energy")
local maxenergy = stats:WaitForChild("maxenergy")
local hold = false
local candamage = true
local touched = false
local coolE = false

 local function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Q and coolE == false then

         local human1 = workspace:WaitForChild(name)
        local human = human1:WaitForChild("Humanoid")   
        local righthand = human.Parent.RightHand
        local torso = human.Parent.HumanoidRootPart





        local blast = Instance.new("Part")
        blast.Shape = "Ball"
        blast.Parent = workspace
        blast.Size = Vector3.new(2,2,2)
        blast.Material = "Neon"
        blast.BrickColor = BrickColor.new("Cyan")
        blast.Transparency = 0.2

        blast.CFrame = righthand.CFrame * CFrame.new(0,0,0)
        local bv = Instance.new("BodyVelocity")
        bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
        bv.Velocity = torso.CFrame.lookVector * 100
        bv.Parent = blast
        blast.CanCollide = false
        wait(0.04)
        blast.CanCollide = true
        energy.Value = energy.Value - 10

blast.Touched:connect(function(hit)
    blast:Destroy()
    local namep = hit.Parent.Name
    local humanp = hit.Parent.Humanoid
    local maxp = humanp.MaxHealth / 100
    local health = humanp.Health
    local statsp = game.ReplicatedStorage:WaitForChild("stats"..namep)
    local defensep = statsp:WaitForChild("defense")
    local dama = ki.Value / defensep.Value



if 1 < dama and dama < 1.1 and candamage == true then -- and here that stop working
    health = maxp - dama * 1
    wait(0.5)
    candamage = true

elseif 1.1 < dama and dama < 1.2 and candamage == true then
    health = maxp - dama * 1.5
    wait(0.5)
    candamage = true


elseif 1.2 < dama and dama < 1.3 and candamage == true then
    health = maxp - dama * 2
    wait(0.5)
    candamage = true


    elseif 1.3 < dama and dama < 1.4 and candamage == true then
    health = maxp - dama * 3
    wait(0.5)
    candamage = true


    elseif 1.4 < dama and dama < 1.5 and candamage == true then
    health = maxp - dama * 5
    wait(0.5)
    candamage = true


    elseif 1.5 < dama and dama < 1.6 and candamage == true then
    health = maxp - dama * 8
    wait(0.5)
    candamage = true


    elseif 1.6 < dama and dama < 1.7 and candamage == true then
    health = maxp - dama * 11
    wait(0.5)
    candamage = true


    elseif 1.7 < dama and dama < 1.8 and candamage == true then
    health = maxp - dama * 20
    wait(0.5)
    candamage = true


    elseif 1.8 < dama and dama < 1.9 and candamage == true then
    health = maxp - dama * 40
    wait(0.5)
    candamage = true


    elseif 1.9 < dama and dama < 2 and candamage == true then
    health = maxp - dama * 60
    wait(0.5)
    candamage = true


    elseif 2 < dama  and candamage == true then
    health = maxp - dama * 100
    wait(0.5)
    candamage = true



end

end)


        local animation = Instance.new("Animation") -- and from here it's working again
        animation.AnimationId = "http//roblox.com/?id=01335430799"
        local animTrack = human:LoadAnimation(animation)
        ki.Value = ki.Value + 5
        animTrack:play()
        coolE = true
        wait(0.4)
        coolE = false
        animTrack:stop()


        end

        end


    game:GetService("UserInputService").InputBegan:connect(onKeyPress)

And it doesn't say nothing in the output, and the whole script is working except for the damage

1
If you print the value of dama on line 60, what value do you see in the console? vector3_zero 1056 — 6y
0
it prints the value of ki.Value / defensep.Value caipira 29 — 6y
0
But what is the actual value? Is it always a number greater than 1? vector3_zero 1056 — 6y
0
no, depends on the ki value and defensep value caipira 29 — 6y
View all comments (3 more)
0
ki value and defensep is stats that the player can train caipira 29 — 6y
1
Your health variable is set to the value of humanoid.Health, but changing the health variable after that only affects the variable, and isn't applied back to the humanoid.Health value. To change the health of the player that is hit you would want to do something like 'humanp.Health = maxp - dama * 1' vector3_zero 1056 — 6y
0
it worked, thx :D caipira 29 — 6y

1 answer

Log in to vote
0
Answered by 5 years ago

Do not use localscript, because that makes that ability not FE use Remotes, localscript (to activate the keyboard) and normal scripts to do it FE

Ad

Answer this question