So, I’m trying to convert the original 2D Game into GUI Game. At first, GUI appeared nicely with sounds after clicking button but, I have no idea why controls doesn’t detect moves or not working. Any helps will be appreciated.
function moveCharacter()
if not worldScrolling then
pos = Vector2.new(gameChar.Position.X.Scale, gameChar.Position.Y.Scale)
if velocity then
if pos.Y + velocity.Y < 0 then
gameChar.Position = gameChar.Position + UDim2.new(velocity.X, 0, 0, 0)
else
gameChar.Position = gameChar.Position + UDim2.new(velocity.X, 0, velocity.Y, 0)
end
end
end
end
function setCharacterVelocity()
if gameChar then
velocity = Vector2.new(0, 0)
if forwards then
gameChar.Image = "http://www.roblox.com/asset/?id=58461425"
velocity = velocity + Vector2.new(0.005, 0)
elseif backwards then
gameChar.Image = "http://www.roblox.com/asset/?id=58462272"
velocity = velocity - Vector2.new(0.005, 0)
end
if falling then
if accelerateBool == false then
accelerateBool = true
accelerateCo = coroutine.create(fallAcceleration)
coroutine.resume(accelerateCo)
end
velocity = velocity + Vector2.new(0, gravity)
end
if jumping then
velocity = velocity - Vector2.new(0, 0.020)
end
end
end
function gameCharMovementStop(key)
if gameChar then
key = key:lower()
if key == "w" then
jumping = false
elseif key =="a" then
backwards = false
elseif key == "d" then
forwards = false
end
end
end
function gameCharMovementStart(key)
local timeNow
if gameChar then
key = key:lower()
if key == "w" then
timeNow = tick()
if timeNow - jumpTimer > 1.0 then
jumpTimer = timeNow
jumping = true
end
elseif key == "a" then
backwards = true
elseif key == "d" then
forwards = true
end
end
end