local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')
local Mouse = Player:GetMouse()
local Power = game.Players.LocalPlayer.leaderstats.Power
while true do
if Power.Value == "Super Speed" then
Mouse.KeyDown:connect(function(key)
if (key == "c") then
if Humanoid.Walkspeed == 50 then
Humanoid.WalkSpeed = 10
elseif Humanoid.WalkSpeed == 10 then
Humanoid.WalkSpeed = 50
end
end
end
end)
COMMUNITY QUESTION
Can someone answer my question on why the ends are never working!?
1 answer
Okay, I think you're a little confused about how the ends work. When you have an elseif statement along with an if statement, it only requires one end, not one for every if.
Here's how you would arrange the ends:
local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')
local Mouse = Player:GetMouse()
local Power = game.Players.LocalPlayer.leaderstats.Power
while true do
if Power.Value == "Super Speed" then
Mouse.KeyDown:Connect(function(key)
if key == "c" then -- You also don't need the parenthesis here.
if Humanoid.Walkspeed == 50 then
Humanoid.WalkSpeed = 10
elseif Humanoid.WalkSpeed == 10 then
Humanoid.WalkSpeed = 50
end -- Ends off the inner-most if statement.
end -- Ends the "if key == "c""
end) -- Ends the KeyDown event.
end -- Ends the original if statement.
I think for the most part, you're just overcomplicating it, but that's okay, as long as you learn in the end.
4 comments
0
Hope it helped!
0
another really dumb answer
0
for Christ's sake, Mouse returns the mouse not the keyboard
0
"key" can only be detected through UserInput/ContextAction service
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
try adding one more "end"
That end gets underlined red!
arrangement is key
also Walkspeed should be "WalkSpeed"
"connect" should be "Connect".
indent ur code
Your 3rd end needs the ) (Instead of the 4th one) and then you need an extra end after that.
Xviperlink I've litterally never had that issue, I used to always to :connect and it worked just fine, but I don't know, I don't really do it anymore.