Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

damage buff script wont work and i dont know why?

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

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)

6 comments

0

oof didnt even notice ill fix it and try after

0

i fixed the lines but it still does 50 dmg even if bootvalue is true

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.

0

nope nothing changed still 50 dmg maybe its the damage script can you look at it more

0

im gonna try to make 2 different scripts that both check the boot value maybe it will work '''_('.')_/'''

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.