What do you want to achieve? Make a control system that make player move if he click on arrow button so I want to make 2 buttons (arrows) one to make player move left and one to make player move right
What is the issue? idk how to make it do that.
What solutions have you thought of so far? Searching on YouTube but I didn’t saw anything about it
btw I already make arrows but idk how to script them to make player move if he click on them
Just like for PC you need to hook your move routines to the “key”. In the case of mobile, “keys” are GUI objects like imageButtons or textbuttons etc…They have events like “TouchTap”. Link the event you want to the move routine.
please anyone help this is my Pc Control script if anyone can edit it and make it work on mobile too
Note : they are local scripts and they are in StarterPlayerScripts
D Script (Right Arrow)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
local Moving = false
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
UserInputService.InputBegan:Connect(function(keyCode, Chatted)
if Chatted then
return
end
local HRP = Character:FindFirstChild("HumanoidRootPart")
if HRP ~= nil and keyCode.KeyCode == Enum.KeyCode.D then
Moving = true
while Moving do
Character.Humanoid:Move(Vector3.new(0,0,1))
RunService.RenderStepped:Wait()
end
end
end)
UserInputService.InputEnded:Connect(function(keyCode)
local HRP = Character:FindFirstChild("HumanoidRootPart")
if HRP ~= nil and keyCode.KeyCode == Enum.KeyCode.D then
Moving = false
Character:MoveTo(HRP.Position)
end
end)
A script (Left Arrow)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
local Moving = false
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
UserInputService.InputBegan:Connect(function(keyCode, Chatted)
if Chatted then
return
end
local HRP = Character:FindFirstChild("HumanoidRootPart")
if HRP ~= nil and keyCode.KeyCode == Enum.KeyCode.A then
Moving = true
while Moving do
Character.Humanoid:Move(Vector3.new(0,0,-1))
RunService.RenderStepped:Wait()
end
end
end)
UserInputService.InputEnded:Connect(function(keyCode)
local HRP = Character:FindFirstChild("HumanoidRootPart")
if HRP ~= nil and keyCode.KeyCode == Enum.KeyCode.A then
Moving = false
Character:MoveTo(HRP.Position)
end
end)