Hey! I’m trying to replicate the D-Pad from controllers because my games involves alot of the D-Pad.
So, I made 8 squares in a big square:
1=frame
0=empty space
1 1 1
1 01
1 1 1
Here’s the code:
while true do
if DPad.Parent.Visible == true then
for i, v in buttons do
v.MouseEnter:Connect(function()
if v:GetAttribute("ButtonID") == 1 then --UP
MoveX = 1
MoveZ = 0
end
if v:GetAttribute("ButtonID") == 2 then --DOWN
MoveX = -1
MoveZ = 0
end
if v:GetAttribute("ButtonID") == 3 then --LEFT
MoveZ = -1
MoveX = 0
end
if v:GetAttribute("ButtonID") == 4 then --RIGHT
MoveZ = 1
MoveX = 0
end
if v:GetAttribute("ButtonID") == 5 then --UPLEFT
MoveX = 1
MoveZ = -1
end
if v:GetAttribute("ButtonID") == 6 then --UPRIGHT
MoveX = 1
MoveZ = 1
end
if v:GetAttribute("ButtonID") == 7 then --DOWNLEFT
MoveX = -1
MoveZ = -1
end
if v:GetAttribute("ButtonID") == 8 then --DOWNRIGHT
MoveX = -1
MoveZ = 1
end
end)
end
Hum:Move(Vector3.new(MoveX, 0, MoveZ), false)
end
task.wait()
end
This basically makes the player move when touching 1 of the frames, but I haven’t found a way to make the player stop. I tried making the variables Move X and Z to 0 when the mouse leaves one of the frames, but it stoped when I hover my mouse to one frame and immediately going to the next. Any help is appreciated :).