Explanation:
GuiSelector.client.lua: This is a LocalScript. Place it inside StarterPlayer -> StarterPlayerScripts in your Roblox project.UserInputService: This service provides information about the user's input devices.LocalPlayer / PlayerGui: Gets the specific player running the script and their GUI container.gui1Name, gui2Name: Important: Change "Gui1" and "Gui2" to the exact names of your ScreenGui objects located in StarterGui.WaitForChild: Waits until the GUIs have loaded for the player before trying to access them.Enabled property to false in the Roblox Studio editor.TouchEnabled is true AND KeyboardEnabled is false. This is a reliable way to detect most mobile phones and tablets.Gui1 and disables Gui2.Gui2 and disables Gui1.Changes:
ResetOnSpawn = false: Added this line for both GUIs. This is important to prevent Roblox from automatically re-enabling the GUI when the player respawns, allowing our script to control it fully.activeGui / inactiveGui: Variables are now used to store references to the GUI that should be active based on the platform and the one that should remain inactive.onCharacterAdded Function:
activeGui when the character loads (initially or after respawning).Humanoid within the character.Humanoid.Died event.Humanoid.Died fires, the connected function runs, setting activeGui.Enabled = false.onCharacterAdded function to the LocalPlayer.CharacterAdded event. This ensures the logic runs every time the player respawns.LocalPlayer.Character already exists when the script first runs and calls onCharacterAdded immediately if it does.character.Destroying:Connect to disconnect the .Died event listener when the character is about to be destroyed, preventing potential memory issues.حسنًا، يبدو أن المشكلة تكمن في كيفية إعادة تمكين الواجهة الرسومية (GUI) بعد عودة اللاعب للحياة (Respawn).
السكريبت السابق كان يجب أن يعمل بشكل صحيح، لكن دعنا نقم ببعض التحسينات ونضيف المزيد من التأكيدات لضمان عمله في كل مرة يعود فيها اللاعب.
النقاط الرئيسية للتأكد منها:
ResetOnSpawn: تأكد تمامًا من أن خاصية ResetOnSpawn لكل من Gui1 و Gui2 معطلة (false) في نافذة الخصائص (Properties) داخل Roblox Studio. هذا مهم جدًا حتى لا يقوم Roblox بإعادة تمكين الواجهة تلقائيًا عند العودة للحياة. السكربت يحاول تعطيلها، لكن من الأفضل التأكد منها في المحرر.Gui1 و Gui2 في السكربت مطابقة تمامًا لأسماء الـ ScreenGui الموجودة داخل StarterGui. أي خطأ إملائي سيمنع السكربت من العثور عليها.LocalScript موجود داخل StarterPlayer -> StarterPlayerScripts.السكريبت المحسن:
سنستخدم نفس المنطق الأساسي ولكن مع تنظيم أفضل للاتصالات بالأحداث وإضافة المزيد من رسائل الطباعة للمساعدة في تتبع ما يحدث.
ما الجديد في هذا السكربت:
print لمساعدتك على رؤية ما يفعله السكربت خطوة بخطوة في نافذة المخرجات (Output). هذا سيساعد في تحديد مكان المشكلة إذا استمرت.diedConnection:Disconnect()): قبل توصيل حدث humanoid.Died لشخصية جديدة، نتأكد من فصل أي اتصال قديم بنفس الحدث. هذا يمنع وجود اتصالات متعددة غير ضرورية.Gui1 و Gui2 في البداية وإصدار تحذير إذا لم يتم العثور عليهما.جرب هذا السكربت وتأكد من مراجعة النقاط الأربعة المذكورة في بداية الإجابة (خاصة ResetOnSpawn وأسماء الواجهات). راقب نافذة المخرجات (Output) بعناية عند اختبار اللعبة، خاصة عند الموت والعودة للحياة.