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

damage buff script wont work and i dont know why?

Asked by 3 years ago

basicaly i have a bootvalue in one of the scripts when i press F it gets buffed and bootvauled sets to true then in another script it checks if value is true if it is it should buff the damage if its false then damage should be normal but it doesnt works help?

heres the script

///////////////////////////////

local tool = script.Parent.Parent
local Blade = tool:WaitForChild("Blade")
local Particle1 = Blade:WaitForChild("Lightning1")
local Buffed = tool:WaitForChild("Buffed")
tool:FindFirstChild("Buffed")

Buffed.Changed:Connect(function()
         if Buffed.Value == true then 
wait(1)         
local debounce = false 
    local HealthLoss = 100

    function OnTouched(Part) 
    if Part.Parent ~= nil then
        if debounce == false and Part.Parent:findFirstChild("Humanoid") ~= nil then 
        debounce = true 

        Part.Parent:findFirstChild("Humanoid"):TakeDamage(HealthLoss) 
    wait(0.4)
debounce = false 
wait(1)
end 
end 
end 
   end
end)


tool:FindFirstChild("Buffed")

if Buffed.Value == false then
    local debounce = false 

wait(1)
local HealthLoss = 50
        function OnTouched(Part) 
        if Part.Parent ~= nil then
        if debounce == false and Part.Parent:findFirstChild("Humanoid") ~= nil then 
        debounce = true 
        Part.Parent:findFirstChild("Humanoid"):TakeDamage(HealthLoss) 
        wait(0.4)
        debounce = false 
            end 
        end 
    end 
    Buffed.Value = false 
end


script.Parent.Touched:connect(OnTouched)

////////////////////////////

1 answer

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

Well I found some possible problems:

1) You do not need lines 5 and 29

2) On lines 15, 18, 38, and 40, you have :findFirstChild() instead of :FindFirstChild. Unfortunately, Lua is really touch-sensitive, so those 4 lines will not work.

Edit:

Ok, so I revised your script, this should work (if you need me to explain any of it, please tell me):

local tool = script.Parent.Parent
local Blade = tool:WaitForChild("Blade")
local Particle1 = Blade:WaitForChild("Lightning1")
local Buffed = tool:WaitForChild("Buffed")

Buffed.Changed:Connect(function()
     if Buffed.Value == true then 
          wait(1)         
          debounce = false 
          HealthLoss = 100
     elseif Buffed.Value == false then
          debounce = false 

          wait(1)
          HealthLoss = 50
     end
     Buffed.Value = false 
end)

function OnTouched(Part) 
     if Part.Parent ~= nil then
          if debounce == false and Part.Parent:findFirstChild("Humanoid") ~= nil then 
               debounce = true 

               Part.Parent:findFirstChild("Humanoid"):TakeDamage(HealthLoss) 
               debounce = false 
               wait(1)
          end 
     end 
end) 

script.Parent.Touched:Connect(OnTouched)
0
oof didnt even notice ill fix it and try after themaxogamer 58 — 3y
0
i fixed the lines but it still does 50 dmg even if bootvalue is true themaxogamer 58 — 3y
0
I just foudn something: move your function out of your if statement. That may do something. I'm not near my roblox studio right now so this answer is 100% hypothetical. Still try it, though. IAmNotTheReal_MePipe 418 — 3y
0
nope nothing changed still 50 dmg maybe its the damage script can you look at it more themaxogamer 58 — 3y
View all comments (2 more)
0
im gonna try to make 2 different scripts that both check the boot value maybe it will work '''\_('.')_/''' themaxogamer 58 — 3y
0
I just revised my answer and your script, tell me if it doesn't work or if you need me to explain any of it. IAmNotTheReal_MePipe 418 — 3y
Ad

Answer this question