✓ Accepted answer
Wrote this a little late on mobile, so sorry if I sound weird. :P
Okay, so the problem is your if statements. They are separate. When you change the mode to “burst”, it moves on to your next statement and sees that the mode is “burst”. Now the mode changes to “semi”, then it moves on to the next statement. Since the mode is now “semi”, the mode changes back to “auto”. See what I mean?
You can easily fix this by using elseif, which I guess “combines” all your statements together. Here’s what your code should look like :
uis.InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
gun.Mode:Play()
if mode == "auto" then
mode = "burst"
print(mode)
elseif mode == "burst" then
mode = "semi"
print(mode)
elseif mode == "semi" then
mode = "auto"
print(mode)
end
end
end)
Now when a statement equals to something, it’ll skip the rest of the if statements and wait for the event to fire again, instead of running through all of the statements and well, you know.
Hope this helped!
1 comment
thank you!!!