#Help

1 messages · Page 1 of 1 (latest)

steady fulcrum
#

i feel this is over complicated

-- .... (other refs)
local playButton = menu:WaitForChild("MenuFrame"):WaitForChild("PLAY")
-- .... (other refs)

local UIS = game:GetService("UserInputService")

playButton.MouseButton1Click:Connect(function()
    
    if UIS.TouchEnabled then
        -- mobile players code
    elseif not UIS.TouchEnabled then
        -- pc players code
    else
        -- error msg, handle error such as closing both mobile and pc gui or something
        warn("Something went wrong!")
    end
    
end)

(sorry to whos typing i was just taking forever)

rain marlin
#

like this? local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local victoryGui = playerGui:WaitForChild("VictoryGui")
local menu = playerGui:WaitForChild("Menu")
local playButton = menu:WaitForChild("MenuFrame"):WaitForChild("PLAY")
-- .... (other refs)

local UIS = game:GetService("UserInputService")

playButton.MouseButton1Click:Connect(function()

if UIS.TouchEnabled then
    -- mobile players code
elseif not UIS.TouchEnabled then
    -- pc players code
else
    -- error msg, handle error such as closing both mobile and pc gui or something
    warn("Something went wrong!")
end

end)

#

idk

steady fulcrum
#

well you have to finish the code crying do you have any scripting experience or is it just all ai?

rain marlin
#

AI... i dont have any scripting experience just some basics...

steady fulcrum
#

i see, try to learn from the code, it's really not as hard as you may think, lua can be very straight forward in some cases

local player = game.Players.LocalPlayer

local playerGui = player:WaitForChild("PlayerGui")
local victoryGui = playerGui:WaitForChild("VictoryGui")
local menu = playerGui:WaitForChild("Menu")
local playButton = menu:WaitForChild("MenuFrame"):WaitForChild("PLAY")
local pcFrame = script.Parent

local uis = game:GetService("UserInputService")

playButton.MouseButton1Click:Connect(function() -- when the play button is pressed..
    if uis.TouchEnabled then -- touch is enabled, therefore this is code for a mobile player
        print("Mobile player!")
        pcFrame.Visible = false -- disable frame visibility for the mobile player
    elseif not uis.TouchEnabled then -- no touch, likely PC or xbox etc
        print("Not a mobile player!")
        pcFrame.Visible = true -- disable frame visibility for the non-mobile player
    else
        warn("Error!") -- you may want to do something here if somehow the player doesn't meet either of the two conditions above
    end
end)
rain marlin
#

that is the full script or what i need to type?

#

or new script idk?

steady fulcrum
#

give it a read, theres no way of me telling if its a your full script or not because i only did what i seen based off the other code, but hopefully its at least what you need currently (read it evilcat )

rain marlin
#

what i typed this: local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local victoryGui = playerGui:WaitForChild("VictoryGui")
local menu = playerGui:WaitForChild("Menu")
local playButton = menu:WaitForChild("MenuFrame"):WaitForChild("PLAY")

local pcFrame = script.Parent
local uis = game:GetService("UserInputService")

local controlsAllowed = false

local function isPC()
return uis.KeyboardEnabled and not uis.TouchEnabled
end

if not isPC() then
pcFrame.Visible = false
end

-- Počáteční stav
pcFrame.Visible = false

-- Funkce pro vyhodnocení viditelnosti
local function updateVisibility()
if controlsAllowed and isPC() and not victoryGui.Enabled then
pcFrame.Visible = true
else
pcFrame.Visible = false
end
end

-- Hlídej kliknutí na PLAY
playButton.MouseButton1Click:Connect(function()
if uis.TouchEnabled then
pcFrame.Visible = false
elseif not uis.TouchEnabled then
pcFrame.Visible = true

end

end)

-- Sleduj změnu VictoryGui.Enabled
victoryGui:GetPropertyChangedSignal("Enabled"):Connect(function()
updateVisibility()
end) and it dont work

#

do you want to type me the script?

steady fulcrum
rain marlin
#

...

steady fulcrum
#

did you try it?

rain marlin
#

yep

rain marlin
#

the right side

#

it shows

#

the frame not the buttons

#

but i want too that when is victory and menu visible it will hide

steady fulcrum
#

what does your workspace look like? take a screenshot like this

rain marlin
#

i sent it what now?

steady fulcrum
#

did you check if you have any errors in the output?

rain marlin
#

yes, and it dont have errors

#

idk whats wrong

rain marlin
#

@steady fulcrum

steady fulcrum
#
local player = game.Players.LocalPlayer

local playerGui = player:WaitForChild("PlayerGui")
local victoryGui = playerGui:WaitForChild("VictoryGui")
local menu = playerGui:WaitForChild("Menu")
local playButton = menu:WaitForChild("MenuFrame"):WaitForChild("PLAY")
local pcGui = script.Parent.Parent

local uis = game:GetService("UserInputService")

playButton.MouseButton1Click:Connect(function() -- when the play button is pressed..
    if uis.TouchEnabled then -- touch is enabled, therefore this is code for a mobile player
        print("Mobile player!")
        pcGui.Enabled = false -- disable gui for the mobile player
    elseif not uis.TouchEnabled then -- no touch, likely PC or xbox etc
        print("Not a mobile player!")
        pcGui .Enabled = true -- enable gui for the non-mobile player
    else
        warn("Error, player doesn't meet either of the two conditions!")
    end
end)

what are those other local scripts for btw?

steady fulcrum
rain marlin
#

^?

#

help pls

cerulean fogBOT
#

studio** You are now Level 8! **studio

steady fulcrum
#

no i quite litterally wrote that lol

#

but the og poster has used ai

#

as mentioned

rain marlin
#

help i want to make gui visible only for mobile, but it dont work, because of smth

steady fulcrum
#

wait a second why are we doing it via play button anyway

#

is the play button meant to turn the gui on?

#

or so you want it to automatically turn on/off gui for devices

#

you could do it via player join event

#

or, crazy idea, dont make 2 different gui's and just size them for all devices rizz

rain marlin
#

oh yea your right i want it to turn it off for only mobile players

steady fulcrum
# rain marlin oh yea your right i want it to turn it off for only mobile players

make sure you're using a local script that is inside the "PC" frame

local uis = game:GetService("UserInputService")

local pcGui = script.Parent.Parent -- make sure this is the "ControlsPC" ScreenGui
local mblGui = script.Parent.Parent.Parent:WaitForChild("ControlsMobile") -- make sure this is the "ControlsMobile" ScreenGui

if game.Loaded then
    if uis.TouchEnabled then
        print("Mobile player!")
        pcGui.Enabled = false
        mblGui.Enabled = true -- turning on mobile gui
    elseif not uis.TouchEnabled then
        print("Not a mobile player!")
        mblGui.Enabled = false
        pcGui.Enabled = true -- turning on pc gui
    else
        warn("Error, player doesn't meet either of the two conditions!") -- error
    end
end
rain marlin
#

it´s frame not gui btw