Mobile Joystick made with only 57 lines of code (works good fr)

It works very good. I also based it off of this Core-Scripts/PlayerScripts/StarterPlayerScripts/ControlScript/MasterControl/Thumbstick.lua at master · Roblox/Core-Scripts · GitHub but a lot more shorter because I thought it was bee movie script

also here model link I uploaded on my main: https://create.roblox.com/store/asset/136991064595622/

and here is rbxm file if you’re stinky and you prefer rbxm file
stickjoything.rbxm (5.2 KB) --I am too lazy to remove the print() thing in the doMove function so you can delete it yourself.

and here is code if you are even more stinky:

local UserInputService = game:GetService("UserInputService")
local ThumbstickInput = nil
local ThumbstickFrame = script.Parent:WaitForChild("Joystick")
local Stick = ThumbstickFrame:WaitForChild("Stick")
local centerPosition = Vector2.new(ThumbstickFrame.AbsolutePosition.x + ThumbstickFrame.AbsoluteSize.x/2,ThumbstickFrame.AbsolutePosition.y + ThumbstickFrame.AbsoluteSize.y/2)
local MoveVector = Vector3.zero
local deadZone = 0.05
local thumbstickSize = ThumbstickFrame.Size.X.Offset
function moveStick(position:Vector2)
	local relativePosition = Vector2.new(position.X - centerPosition.X, position.Y - centerPosition.Y)
	local length = relativePosition.magnitude
	local maxLength = ThumbstickFrame.AbsoluteSize.x/2
	length = math.min(length, maxLength)
	relativePosition = relativePosition.unit * length
	Stick.AnchorPoint = Vector2.new(1,1)
	Stick.Position = UDim2.new(0.5, relativePosition.X + Stick.AbsoluteSize.X/2, 0.5, relativePosition.Y + Stick.AbsoluteSize.Y/2)
end
function doMove(direction)
	MoveVector = direction / (thumbstickSize/2)
	local inputAxisMagnitude = MoveVector.magnitude
	if inputAxisMagnitude < deadZone then
		MoveVector = Vector3.new()
	else
		MoveVector = MoveVector.unit * ((inputAxisMagnitude - deadZone) / (1 - deadZone))
		-- NOTE: Making currentMoveVector a unit vector will cause the player to instantly go max speed
		-- must check for zero length vector is using unit
		MoveVector = Vector3.new(MoveVector.x, 0, MoveVector.Y)
	end
	return MoveVector
end
function InputBegan(input:InputObject)
	if ThumbstickInput or input.UserInputType ~= Enum.UserInputType.Touch then
		return
	end
	ThumbstickInput = input
	local direction = Vector2.new(input.Position.X - centerPosition.X, input.Position.Y - centerPosition.Y)
	doMove(direction)
	moveStick(input.Position)
end
UserInputService.TouchEnded:Connect(function(input)
	if ThumbstickInput ~= input or input.UserInputType ~= Enum.UserInputType.Touch then
		return
	end
	ThumbstickInput = nil
	Stick.Position = UDim2.new(0.5,0,0.5,0)
	Stick.AnchorPoint = Vector2.new(0.5,0.5)
end)
UserInputService.TouchMoved:Connect(function(input,processed)
	if input == ThumbstickInput then
		local direction = Vector2.new(input.Position.X - centerPosition.X, input.Position.Y - centerPosition.Y)
		doMove(direction)
		moveStick(input.Position)
	end
end)
Stick.InputBegan:Connect(InputBegan)
ThumbstickFrame.InputBegan:Connect(InputBegan)
5 Likes