You can write your topic however you want, but you need to answer these questions:
I’m trying to achieve a selection of mobile and pc
The issue with this is every time the player dies. The selection doesn’t go and to where it’s use to
be, It just resets everything starting from square one meaning they have to select if they are on pc or mobile you would think to make a datastore but the problem with this is I want to allow the player to choose every time they join the game NOT when they reset or die therefore to say (NOTE: I do know about the plugin, but to provide the best experience for the game we made two different ui’s)
What I’m thinking of a solution is 1.Clone the ui and destroy the new one given (Issue:My game is gonna do a lot with ui’s therefore i can’t exactly just clone it to the player) 2. Some how pass a value change and another code check’s for that value change and destroy the other ui’s(Issue: Isn’t it gonna change the value every time I respawn)
local Tweenservice = game:GetService("TweenService")
local ScreenMobile = script.Parent.Parent.Parent.MainGuiMobile
local Effect = script.Parent.Parent.Parent.Effects.DarkEffect
local ScreenPC = script.Parent.Parent.Parent.MainGuiPC
local Select = script.Parent.Parent.Parent.Select
local Enter = workspace.Game.Sounds.UISounds.Buttons.Enter
local Leave = Enter.Parent.Leave
local Click = Enter.Parent.Click
local FadeIn = {BackgroundTransparency = 0.5}
local FadeOut = {BackgroundTransparency = 0.9}
local FadeEffect = Tweenservice:Create(Effect,TweenInfo.new(10,Enum.EasingStyle.Sine),{BackgroundTransparency = 1})
function TweenTransparency(...)
local Args = {...}
Tweenservice:Create(Args[1],TweenInfo.new(0.75,Enum.EasingStyle.Sine),Args[2]):Play()
end
for _, button in pairs(script.Parent.Parent.Frame:GetDescendants()) do
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
if button.Name == "PC" then
Select.Enabled = false
FadeEffect:Play()
ScreenPC.Enabled = true
elseif button.Name == "Mobile" then
Select.Enabled = false
FadeEffect:Play()
ScreenMobile.Enabled = true
end
end)
button.MouseEnter:Connect(function()
if button.Name == "PC" then
TweenTransparency(button,FadeIn)
elseif button.Name == "Mobile" then
TweenTransparency(button,FadeIn)
end
end)
button.MouseLeave:Connect(function()
if button.Name == "PC" then
TweenTransparency(button,FadeOut)
elseif button.Name == "Mobile" then
TweenTransparency(button,FadeOut)
end
end)
end
end
nothing will happen when the player resets? It is on Join so they only get it once when they first enter the game, then when they click either PC or Mobile, have the gui destroy itself
and if you only show this menu once per join, you maybe want a “Confirm” button
Then how will the game know what the player chose. The only solution is once the player chose a device, the game marks the player as that device. Then if the player dies and the game detects that the player chose a device, it will destroy the UIs and clone the UIs that the player chose.
game.Players.PlayerAdded:Connect(function(player)
if not ChosenDevices[player.UserId] then
return
end
if ChosenDevices[player.UserId] == "mobile" then
--Load mobile UI
elseif ChosenDevices[player.UserId] == "pc" then
--Load PC UI
end
end)
for _, button in pairs(script.Parent.Parent.LeftMiddlePC:GetDescendants()) do
for _, button in pairs(script.Parent.Parent.LeftMiddlePhone:GetDescendants()) do
local Inventoryname = script.Parent.Parent.LeftMiddlePhone.InventoryName
local Inventoryname = script.Parent.Parent.LeftMiddlePC.InventoryName
Okay So those are the two things That change for mobile or pc nothing more How do i change variable or the for loop Depending on the choice they choose?