I have my script set up where a loop is resumed when the player is walking and is paused while the player is stopped. When I run the script it runs correctly for the first time, but after that the loop seems to not work. Does anyone know what is wrong with my script?
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Figure = Player.Character
local Mouse = Player:GetMouse()
local i = 0
local W = false
CamMovment = coroutine.create(function()
while W == true do
wait()
print(i)
i = i + 1
end
end)
Mouse.KeyDown:connect(function(key)
if key == "w" then
W = true
coroutine.resume(CamMovment)
end
end)
Mouse.KeyUp:connect(function(key)
if key == "w" then
W = false
coroutine.yield(CamMovment)
end
end)
