So I currently made a small minigame GUI that functions as a mouse dragging game, go from point A to point B without hitting the walls and you win. Everything works fine on mobile and PC but XBOx obviously doesn’t work.
As you can see you have to click, hold and drag the red square to the green square. Like I said this works perfectly for PC and mobile but XBOX controllers doesn’t work. I want to make it so when you use the DPAD it moves but I have no idea how to do this:
events.Open.OnClientInvoke = function(folder)
local GUI
--If on tablet or phone
if UIS.TouchEnabled == true then
GUI = folder.Parent.PhoneMinigames:GetChildren()[math.random(1, #folder.Parent.PhoneMinigames:GetChildren())]:Clone()
GUI.Parent = player.PlayerGui
else
GUI = folder:GetChildren()[math.random(1, #folder:GetChildren())]:Clone()
GUI.Parent = player.PlayerGui
end
GUI.Enabled = true
local background = GUI:WaitForChild("Background")
local frame = background:WaitForChild("Circle")
local walls = background:WaitForChild("Walls")
local jumpscare = GUI:WaitForChild("Jumpscare")
local dragToggle = nil
local dragSpeed = 0
local dragStart = nil
local startPos = nil
local running = false
local function hitWall()
if running == false then
running = true
dragToggle = false
jumpscare.Visible = true
GUI.JumpscareSound:Play()
wait(3)
jumpscare.Visible = false
GUI:Destroy()
running = false
end
end
local function Collide(Gui1, Gui2)
local AP1, AS1 = Gui1.AbsolutePosition, Gui1.AbsoluteSize
local AP2, AS2 = Gui2.AbsolutePosition, Gui2.AbsoluteSize
local dP = AP2 - AP1
if dP.X < 0 then
if dP.Y < 0 then
if AS2.X > math.abs(dP.X) and AS2.Y > math.abs(dP.Y) then
if Gui1.Name == "Finish" then
return "FINISHED"
else
return true
end
else
return false
end
elseif dP.Y > 0 then
if AS2.X > math.abs(dP.X) and AS1.Y > math.abs(dP.Y) then
if Gui1.Name == "Finish" then
return "FINISHED"
else
return true
end
else
return false
end
else
return false
end
elseif dP.X > 0 then
if dP.Y < 0 then
if AS1.X > math.abs(dP.X) and AS2.Y > math.abs(dP.Y) then
if Gui1.Name == "Finish" then
return "FINISHED"
else
return true
end
else
return false
end
elseif dP.Y > 0 then
if AS1.X > math.abs(dP.X) and AS1.Y > math.abs(dP.Y) then
if Gui1.Name == "Finish" then
return "FINISHED"
else
return true
end
else
return false
end
else
return false
end
else
return false
end
end
local notFinished = nil
local function updateInput(input)
for _, wall in pairs(walls:GetChildren()) do
local framesCollision = Collide(wall, frame)
if framesCollision and framesCollision ~= "FINISHED" then
notFinished = false
elseif framesCollision and framesCollision == "FINISHED" then --IF THE PLAYER HAS REACHED THE END
end
end
if notFinished == false then
notFinished = nil
hitWall()
end
local delta = input.Position - dragStart
local position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X,
startPos.Y.Scale, startPos.Y.Offset + delta.Y)
game:GetService('TweenService'):Create(frame, TweenInfo.new(dragSpeed), {Position = position}):Play()
end
frame.InputBegan:Connect(function(input)
game.ReplicatedStorage.MainEvents.Test:FireServer(input.UserInputType)
if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) and running == false then
dragToggle = true
dragStart = input.Position
startPos = frame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragToggle = false
end
end)
end
end)
UIS.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch and running == false then
if dragToggle == true and GUI.Enabled == true then
if running == true and dragToggle == false then return end --If currently in the jumpscare
updateInput(input)
end
end
end)
end