I have a vehicle system for mobile and I need the textButtons to work properly.
Here is my primary goal: When mouseEnter and mouseDown on the textbutton, then the code runs, and when mouse is on the textbutton but the mouse isn’t holding, then the code doesn’t run.
I already have it working by using mouseEnter, but when the mobile player taps on it, then the code keeps running since the mouse is technically still on the textbutton. I don’t know how to achieve this so I need help.
for i, v in movementFrame:GetChildren() do
if v:IsA("TextButton") then
v.MouseEnter:Connect(function()
if v.Name == "UpButton" then
print("Up")
end
if v.Name == "DownButton" then
print("Down")
end
if v.Name == "LeftButton" then
print("Left")
end
if v.Name == "RightButton" then
print("Right")
end
end)
end
end
use user input service or context action
I kinda did that but it doesn’t work that well
for i, v in movementFrame:GetChildren() do
if v:IsA("TextButton") then
v.MouseEnter:Connect(function()
while isHolding do
RunService.Heartbeat:Wait()
if v.Name == "UpButton" then
print("Up")
end
if v.Name == "DownButton" then
print("Down")
end
if v.Name == "LeftButton" then
print("Left")
end
if v.Name == "RightButton" then
print("Right")
end
end
end)
end
end
I really think you should use ContextActionService and use the mobile UI button thing.
How would I use context action service. The reason why im not using the mobile ui is because it’s really hard to control the vehicle so that’s why I’m making the controls custom using gui.
1 Like
hmmm how about u just make it so that it responds to the joystick
Is the player module already in the player when starting?
Maybe it is but i don’t know. I’m sure it is though. I’m gonna open studio and i’ll tell u if I see it in the playerscripts when running the game
Alright I just checked. Yes, it’s in the player. by default
I tried to implement it but its basically the same thing using a vehicle seat but easier. Besides that, it also only works on the local script so It’s harder to get it started. That’s also a reason why I want to use GUI.
I forgot to mention this but the main reason why I’m using gui for mobile is because the vehicle always turns left or right even if you’re joystick is pointing forward. The movement is more precise on pc so it works perfectly fine there.