How to make this script mobile supported?

  1. What do you want to achieve? Keep it simple and clear!
    Mobile support on the script
  2. What is the issue? Include screenshots / videos if possible!
    Im not a mobile support expert so i do not know how to do these type of stuff
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Im not sure if i should use context action service or mobile joystick or smth idk
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")



local player = Players.LocalPlayer
local addSideMax = 1

local finalVector = Vector3.new(0, 0, -1)



RunService.RenderStepped:Connect(function()
	if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
		local humanoidRootPart = player.Character.HumanoidRootPart
	end
end)

RunService:BindToRenderStep("move", Enum.RenderPriority.Character.Value + 1, function()
	if player.Character then
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid:Move(finalVector, true)
		end
	end
end)


UserInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.A then
		finalVector = finalVector + Vector3.new(-addSideMax,0,0)
	elseif inputObject.KeyCode == Enum.KeyCode.D then
		finalVector = finalVector + Vector3.new(addSideMax,0,0)
	end
end)

UserInputService.InputEnded:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.A then
		finalVector = finalVector + Vector3.new(addSideMax,0,0)
	elseif inputObject.KeyCode == Enum.KeyCode.D then
		finalVector = finalVector + Vector3.new(-addSideMax,0,0)
	end
end)

Use ContextActionService | Documentation - Roblox Creator Hub

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.