Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can detect when a player puts the joystick up on mobile?

Im trying to make a cloud, and I have the computer working, but I want to know how I would make it work for players. For now, I just want to know when player puts his joystick up on mobile. Any help on this?

3 comments

0

if you mean the joystick GUI, just detect if that movement is equivalent to W on a keyboard

0

How, thats what I want to know! Ill give you rep if you post how man.

0

Would like to know how do this to.. maybe it has to do something with accelerometer or gryroscope?

1 answer

Local Script

game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.Up or inputObject.KeyCode == Enum.KeyCode.W or inputObject.KeyCode == Enum.KeyCode.DPadUp or inputObject.KeyCode == Enum.KeyCode.Thumbstick1 then
		print("Cloud Movement")
end
end)

The above script would actually work on all devices (mobile, pc, console, tablet)

The Enum.KeyCode that relates to the Mobile device is the Enum.KeyCode.DPadUp in this case.

EDIT: Try using this:

local player = game.Players.LocalPlayer
repeat wait() until player.Character ~= nil and workspace:FindFirstChild(player.Name) ~= nil
player.Character.Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if player.Character.Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
		print("Cloud Movement 2")
	end
end)

There's apparently no Enum.KeyCode for the Mobile Phones yet, so MoveDirection will have to suffice to determine the movement.

1 comment

0

didn't work.

This discussion is preserved as it was. New answers, comments, and votes are closed.