So, I had a cool idea to make a 2D Roblox Game only using Guis. I've seen one YouTuber do it before, and I wanted to try and make my own version. Everything was going great until I ran into a problem.
In my game, I set both the Player's WalkSpeed and JumpPower to 0, then inserted a Frame inside of a ScreenGui in the StarterGui.
Then, I made a LocalScript inside of the Frame that controls the Frame's movement.
However, when I tested the game out and clicked the "A" and "D" keys (which are used to control the Frame to go Left and Right), it would only let me go a certain distance before stopping, even though I was still holding down the key for that direction.
What I am trying to do is to get the Frame to Copy Roblox's Actual movement system, like when you hold down the "W" key, your character moves forwards until you let go of the "W" key.
What my Frame is doing is it is stopping at a certain distance even though I am still holding down the key.
This is the Frame's Gui Movement LocalScript:
local TweenService = game:GetService("TweenService") local Player = script.Parent.Parent local UIS = game:GetService("UserInputService") game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false) local jumpCooldown = 0.8 local debounce = false --//Player Movement\\-- UIS.InputBegan:Connect(function(Key) local PosX = Player.Position.X local PosY = Player.Position.Y if Key.KeyCode == Enum.KeyCode.W and Player.Position ~= UDim2.new(PosX.Scale, 0, 0.1, 0) or Key.KeyCode == Enum.KeyCode.D and Player.Position ~= UDim2.new(PosX.Scale, 0, 0.1, 0) then Player:TweenPosition(UDim2.new(PosX.Scale + 0.1, 0, PosY.Scale, 0), "Out", "Linear", 0.2) end if Key.KeyCode == Enum.KeyCode.S and Player.Position ~= UDim2.new(PosX.Scale, 0, 0.1, 0) or Key.KeyCode == Enum.KeyCode.A and Player.Position ~= UDim2.new(PosX.Scale, 0, 0.9, 0) then Player:TweenPosition(UDim2.new(PosX.Scale - 0.1, 0, PosY.Scale, 0), "Out", "Linear", 0.2) end if Key.KeyCode == Enum.KeyCode.Space and Player.Position ~= UDim2.new(PosY.Scale, 0, 0.6, 0) then if debounce == false then debounce = true Player:TweenPosition(UDim2.new(PosX.Scale, 0, PosY.Scale - 0.4, 0), "Out", "Sine", 0.6) wait(0.6) Player:TweenPosition(UDim2.new(PosX.Scale, 0, PosY.Scale + 0.01, 0), "Out", "Bounce", 0.8) wait(jumpCooldown) debounce = false end end end)
Any help on this?
You can do this with UIS.InputBegan and UIS.InputEnded.
Use a variable. When UIS.InputBegan fires, the variable goes true. When UIS.InputEnded fires, the variable goes false. Then make a loop to check the variable value and move or stop that frame accordingly