So you see i have like a button in PC devices where if you click it or your mouse enters the button it toggles to true and so it opens a gui, and if you click again or get your mose inside it, it will toggle to false but in mobile that is not the case, even with a mobile button so what happens is that its just toggling when you are pressing it but if you stop pressing it will toggle false hres the code
script.Parent.MouseButton1Click:Connect(function() game.Lighting.Camera:FireServer() end) local Context = game:GetService("ContextActionService") local function mobile() game.Lighting.Camera:FireServer() end Context:BindAction("Camera",mobile,true,Enum.KeyCode.ButtonX) Context:SetPosition("Camera",UDim2.new(0.386, 0,0.674, 0))
that is in a local script, when i do it with desktop devces or with a mouse it works well but in mobile it doesnt work that way and heres the script which detects the serverfired
game.Lighting.Camera.OnServerEvent:Connect(function() workspace.CamsUp.Value = not workspace.CamsUp.Value end)
i hope that described well what is my problem
I'm not exactly sure what the error is, it could be your path defining. But also, I don't really use ContextActionService but I did rewrite this to possibly help you!
local Lighting = game:GetService("Lighting") local ContextActionService = game:GetService("ContextActionService") local GuiButton = (script.Parent:IsA("GuiButton") and script.Parent) or script:FindFirstAncestorOfClass("GuiButton") local ButtonEvent = function() local Success,Returned = pcall(function() Lighting:FindFirstChild("Camera"):FireServer(); end); if not Success then warn((typeof(Returned) == ("string") and Returned) or tostring(Returned)); end end GuiButton.MouseButton1Click:Connect(ButtonEvent) ContextActionService:BindAction(("CameraEvent"),ButtonEvent,true,Enum.KeyCode.ButtonX); ContextActionService:SetPosition(("CameraEvent"),ButtonEvent,true,Enum.KeyCode.ButtonX);