Universal Script 📌
2.3k Views
10.1k Executions

Mobile WASD Joystick

10K executions
Universal Script 📌
theobscured102
theobscured102Published 10
7 months ago
Get an executor
Please login to perform these actions:

Does it work?

No reports yet

No reports yet. Tried it? Be the first to say.

Also noticed:

Description

Just a silly script I put together. It makes your joystick behave more like WASD on a keyboard. It also supports proper diagonal movement, so inputs combine the same way WASD does.

View Raw
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local playerScripts = player:WaitForChild("PlayerScripts")
local controls = require(playerScripts:WaitForChild("PlayerModule")):GetControls()

local BIND_NAME = "CameraAlignedMobileMove"
local DEADZONE = 0.05
local SNAP_THRESHOLD = 0.3

local humanoid

local function getHumanoid()
	local character = player.Character or player.CharacterAdded:Wait()
	return character:WaitForChild("Humanoid")
end

local function unbind()
	RunService:UnbindFromRenderStep(BIND_NAME)
end

local function flatUnit(vector)
	local flat = Vector3.new(vector.X, 0, vector.Z)
	return flat.Magnitude > 0 and flat.Unit or Vector3.zero
end

local function snap(x, z)
	local sx = math.abs(x) > SNAP_THRESHOLD and (x > 0 and 1 or -1) or 0
	local sz = math.abs(z) > SNAP_THRESHOLD and (z > 0 and 1 or -1) or 0

	local vector = Vector3.new(sx, 0, sz)
	return vector.Magnitude > 0 and vector.Unit or Vector3.zero
end

local function hookCharacter(character)
	unbind()
	humanoid = character:WaitForChild("Humanoid")



Comments

1
Log in to join the conversation. Login
Botz's profile picture
Botz7 months ago

I've been looking for this script everywhere thank you man

1

More universal scripts

See all
Script hub
16.0k
93.4k
Bumped 29 minutes ago
Key System

Script hub

Kronos New

Universal Script 📌
48.5k
46.6k
Bumped 3 hours ago
Universal Script 📌
1.5k
1.3k
Bumped 6 hours ago
Universal Script 📌
4.2k
56.5k
Bumped 7 hours ago
Universal Script 📌
7.1k
71.8k
Bumped 7 hours ago
Script hub
3.5M
1.2M
Bumped 8 hours ago
Key System