I must make a mouse unlocker when a phone is opened.i used userinputservice for that but the mouse is still not getting unlocked.if i dont do it,then pc players will not able to control phone.
i tried enable modal in phone but they seems do not work.
script
local UIS = game:GetService("UserInputService")
local Plr = game:GetService("Players").LocalPlayer
local NotificationService = require(game:GetService("ReplicatedStorage").Services.Notification)
if UIS.TouchEnabled == true then
Plr:WaitForChild("PlayerGui").MobileButtons.Enabled = true
end
-- Disable --
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
-- Functions --
local function Phone()
script.Click:Play()
local UI = Plr.PlayerGui:WaitForChild("Phone")
if UI.PhoneFrame.Screen.Values.IsUsing.Value == true then
game:GetService("ReplicatedStorage").Phone:FireServer("R")
UI.PhoneFrame.Screen.Values.IsUsing.Value = false
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
game:GetService("TweenService"):Create(UI.PhoneFrame,TweenInfo.new(0.25,Enum.EasingStyle.Quad),{Position = UDim2.new(0.745,0,1.2,0)}):Play()
task.wait(0.25)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
else
game:GetService("ReplicatedStorage").Phone:FireServer("A")
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
UIS.MouseBehavior = Enum.MouseBehavior.Default
UI.PhoneFrame.Screen.Values.IsUsing.Value = true
game:GetService("TweenService"):Create(UI.PhoneFrame,TweenInfo.new(0.25,Enum.EasingStyle.Quad),{Position = UDim2.new(0.745,0,0.452,0)}):Play()
end
end
-- Events --
UIS.InputBegan:Connect(function(input,gp)
if gp then
return
end
if input.KeyCode == Enum.KeyCode.Tab then
Phone()
end
end)