Value not going down when minusing

I have a dodge value that activates whenever there’s a change of value in a boss’s health and for some reason it teleports the boss but doesn’t minus the dodge value? This is the dodge script,

local Value = script.Parent.Parent.Health
local Value2 = script.Parent.Parent.Boss.MaxHealth
local Dodges = script.Parent.Value
local Boss = script.Parent.Parent
Value.Changed:Connect(function(NewValue)
	local dodgespot = Vector3.new(math.random(-20,20), 0, math.random(-20,20))
	Value.Value = Value2
	Dodges = Dodges -1
	Boss:TranslateBy(dodgespot)
end)

Help would be greatly appreciated thank you!

1 Like

What is script.Parent and its ancestors? Is that a model? Mind showing a screenshot of it?( the model and humanoid + relevant values(

2 Likes

image
image

2 Likes

I see, have yoy tried to put a few prints to see if there are any errors?
Try to print values your boss has.

I see the issue -
replace this -
local Dodges = script.Parent.Value
with:
local Dodges = script.Parent

You could also shorten the sub by doing Dodges.Value -=1

Sorry for being a bit late, had to go.

1 Like

Don’t do Dodges = script.Parent.Value, remove the .Value altogether. Otherwise you are changing a representation of the value, not the actual thing.

Then when subtracting do Dodges.Value -= 1

1 Like

image

local Value = script.Parent.Parent.Health
local Value2 = script.Parent.Parent.Boss.MaxHealth
local Dodges = script.Parent.Value
local Boss = script.Parent.Parent
Value.Changed:Connect(function(NewValue)
	local dodgespot = Vector3.new(math.random(-20,20), 0, math.random(-20,20))
	Value.Value = Value2
	Dodges = Dodges -1
	print(Dodges)
	Boss:TranslateBy(dodgespot)
end)

Doesnt seem to work still

2 Likes

I’ll try this and see what happens!

1 Like


This appeared?

Did you change the local Dodges = line too? On line 3 you should do

local Dodges = script.Parent

Yes that is what I did but it didn’t seem to work

So your code currently looks like this?

local Value = script.Parent.Parent.Health
local Value2 = script.Parent.Parent.Boss.MaxHealth
local Dodges = script.Parent
local Boss = script.Parent.Parent
Value.Changed:Connect(function(NewValue)
	local dodgespot = Vector3.new(math.random(-20,20), 0, math.random(-20,20))
	Value.Value = Value2
	Dodges.Value = Dodges.Value -1
	print(Dodges.Value)
	Boss:TranslateBy(dodgespot)
end)

Yeah I don’t think I applied the edits though but now it seems to work! Now I just have to sort out it decreasing tons by adding a debounce I think when the player hits the boss hehe!

1 Like