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

Did I indent the right part?

Asked by 5 years ago

I made a part and put in a script and a value. I wanted something to happen if the value got to zero but whenever it got to zero nothing happened. I put this in the script

script.Parent.Touched:Connect(function(hit)
if script.Parent.Value.Value > 0 then
if hit.Parent.Name == "Hammer" then
script.Parent.Value.Value = script.Parent.Value.Value - 10
else if script.Parent.Value.Value <= 0 then
print("k")
end
end
end
end)

it didn't work I think it is because of the second and fourth line. To fix the problem I tried indenting the 2 lines below the second line but it still wouldn't work. I also tried indenting the second last line none of them worked.

0
i assume because the elseif that cecks if its zero gotta match up with the first if statment that checks if its bigger than zero starmaq 1290 — 5y
0
and youre putting that elseif with the hamme check, which is wrong i guess starmaq 1290 — 5y
0
what? how do I do that? turquoise_monkeyman 32 — 5y
0
On the second line, try using == instead of >, you are detecting if the value is higher than 0 if you use > instead of == MArzalAlBuchariZ 33 — 5y
0
oh I see anything else? turquoise_monkeyman 32 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Mistakes 1. You used > which detect if the value is higher than zero, you might be looking for == instead which detect if the value is 0 2. You included the "elseif" statement on the second statement instead of the first statement. 3. You seperated the "else" and the "if", you might be looking for the "elseif" statement.

lua script.Parent.Touched:Connect(function(hit) if script.Parent.Value.Value == 0 then if hit.Parent.Name == "Hammer" then script.Parent.Value.Value = script.Parent.Value.Value - 10 else return end elseif not script.Parent.Value.Value == 0 then print("k") end end) ```

0
actually I want to check on the second line if it is higher than 0 and on the 6th line if it is 0  turquoise_monkeyman 32 — 5y
0
I think it is because it is a tool turquoise_monkeyman 32 — 5y
Ad

Answer this question