I'm trying to make it so that if you press E, your stance will be passive, and if you press E again your stance will be aggressive. If I press E, the game successfully changes the status to "Passive", but if I press it again the status stays at "Passive".
local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local mode = Instance.new("StringValue", char.Torso)
local mouse = Player:GetMouse()
wait(1)
mode.Name = "mode"
local GUI = Instance.new("ScreenGui", Player.PlayerGui) -- //\\//ACTION TOGGLE VISUAL\\//\\ --
GUI.Name = "FDF"
local PA = Instance.new("TextButton", GUI)
PA.Size = PA.Size +UDim2.new(0,100,0,25)
PA.Draggable = true
PA.Text = "Status (E/<Attacks>)"
PA.Position = PA.Position +UDim2.new(0,1250,0,25)
script.Disabled = false
-- VARIABLES ABOVE --
-- FUNCTION BELOW --
function onKeyDown(key) -- ACTION TOGGLE --
key = key:lower()
if key == "e" then
mode.Value = "Passive"
PA.Text = mode.Value
if mode.Value == "Passive" then
char.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=700567206"
char.Animate.idle.Animation2.AnimationId = "http://www.roblox.com/asset/?id=700567206"
char.Humanoid.WalkSpeed = 8
end -- ends 'if mode == passive'
end -- ends if
end -- ends function
function onKeyDown2(key) -- ACTION TOGGLE --
if key == "e" then
mode.Value = "Aggressive"
PA.Text = mode.Value
char.Humanoid.WalkSpeed = 25
end -- ends if
end -- ends function
mouse.KeyDown:connect(onKeyDown)
mouse.KeyDown:connect(onKeyDown2)
Any solutions?

2 comments
Interesting suggestion but no cigar. It still doesn't toggle back and forth it only runs the first button press.
It should toggle back and forth according to what I tested. I would recommend increasing the wait time on line 13 just in-case you were holding the key for too long as I did my first go around.