Hi Guys, so I made a placement system for my game, but my problem here is that it can’t be compatible for mobile. I don’t have any idea regarding how to make a mobile placement system. Help is very much required. Thanks
I would imagine you have to incorporate more GUI element buttons instead of pressing a key on the keyboard.
I would look at games like build a boat for treasure for inspiration.
1 Like
Another thing is using the UserInputService
local function onInput(input, gameProcessedEvent)
if gameProcessedEvent then
return
end
if input.UserInputType == Enum.UserInputType.Touch then
if input.UserInputState == Enum.UserInputState.Begin then
-- Create a new instance of the object to place
local newObject = objectToPlace:Clone()
newObject.Parent = game.Workspace
-- Set the initial position of the new object to the touch position
local touchPosition = input.Position
newObject.Position = Vector3.new(touchPosition.X, touchPosition.Y, 0)
-- Listen for the touch end event to finalize placement
local touchEndedConnection
touchEndedConnection = UserInputService.TouchEnded:Connect(function(endInput, endGameProcessedEvent)
if endInput.UserInputType == Enum.UserInputType.Touch then
if endInput.UserInputState == Enum.UserInputState.End then
-- Disconnect the touch ended connection
touchEndedConnection:Disconnect()
-- Finalize the placement of the new object
newObject.Position = Vector3.new(endInput.Position.X, endInput.Position.Y, 0)
end
end
end)
end
end
end
https://create.roblox.com/docs/reference/engine/classes/UserInputService
Disclaimer: This code was partially or fully AI-generated from: https://chat.openai.com/chat
2 Likes