-
I’m trying to make a base editing system where you can select and edit conveyors
-
For some reason, when I don’t tap on a conveyor, or if I tap on the “Remove” button it stops me from moving(on mobile)
-
I’m pretty sure this is because of the functions not returning Enum.ContextActionResult.Pass but it seems that all of the functions are so I dont know why this is happening.
I think it might be because of rebinding the actions in editor.Enable but im not sure
focusMode:
local function focusMode(_, inputState : Enum.UserInputState)
if inputState ~= Enum.UserInputState.End then return Enum.ContextActionResult.Pass end
if hovering then cleanup() end
local result = cast()
if result and result.Instance then
local model = result.Instance:FindFirstAncestorOfClass("Model")
if model then
hovering = model:HasTag("Upgrade") and model or nil
selectionBox.Adornee = model
selectionBox.Parent = model
end
else
hovering = nil
end
if not hovering then
editor.Enable()
return Enum.ContextActionResult.Pass
end
local sucess, msg = pcall(function()
if currentOptions then currentOptions:Destroy() end
local modelCenter = GetModelCenter(hovering) + Vector3.new(0, 1, 0)
currentOptions = buildOptions:Clone()
billboardOptions = currentOptions.BuildOptions
currentOptions.Parent = hovering
currentOptions.Position = modelCenter
selectionBox.Adornee = hovering
currentOptions.Parent = hovering
billboardOptions.Parent = player.PlayerGui
billboardOptions.Adornee = currentOptions
global.Editing = hovering
upgradeConnection = billboardOptions.Upgrade.Activated:Connect(function()
initUpgrade(nil, Enum.UserInputState.End)
end)
removeConnection = billboardOptions.Sell.Activated:Connect(function()
removeFunc(nil, Enum.UserInputState.End)
end)
RunService:UnbindFromRenderStep(RENDER_ACTION)
ContextActionService:UnbindAction(UPGRADE_ACTION)
ContextActionService:BindAction(UPGRADE_ACTION, initUpgrade, false, Enum.KeyCode.Q)
ContextActionService:BindAction(REMOVE_ACTION, removeFunc, false, Enum.KeyCode.R)
end)
if not sucess then
warn(debug.traceback(msg))
end
return Enum.ContextActionResult.Pass
end
removeFunc:
local function removeFunc(_, inputState : Enum.UserInputState)
if inputState ~= Enum.UserInputState.End or not hovering then return end
local sucess, msg = pcall(function()
global.EditorEvent:FireServer(
hovering:GetAttribute("Category"),
removeValues[hovering:GetAttribute("Category")],
global.Editing
)
editor.Enable()
end)
if not sucess then warn(msg) end
return Enum.ContextActionResult.Pass
end
function editor.Enable()
cleanup()
unbindAll()
RunService:BindToRenderStep(RENDER_ACTION, Enum.RenderPriority.Camera.Value, selectionMode)
ContextActionService:BindAction(FOCUS_ACTION, focusMode, true, Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch)
end