JIT
Mobile PC GUI Script
ابا سكربت اذا لاعب جوال يطلعلعه gui 1 واذا كبيوتر Gui2

Explanation:

  1. GuiSelector.client.lua: This is a LocalScript. Place it inside StarterPlayer -> StarterPlayerScripts in your Roblox project.
  2. UserInputService: This service provides information about the user's input devices.
  3. LocalPlayer / PlayerGui: Gets the specific player running the script and their GUI container.
  4. gui1Name, gui2Name: Important: Change "Gui1" and "Gui2" to the exact names of your ScreenGui objects located in StarterGui.
  5. WaitForChild: Waits until the GUIs have loaded for the player before trying to access them.
  6. Initial Disable: The script makes sure both GUIs start disabled. You should also set their Enabled property to false in the Roblox Studio editor.
  7. Platform Detection:
    • It checks if TouchEnabled is true AND KeyboardEnabled is false. This is a reliable way to detect most mobile phones and tablets.
    • If it's mobile, it enables Gui1 and disables Gui2.
    • Otherwise (it assumes PC, console, or touch-enabled laptop), it enables Gui2 and disables Gui1.
  8. Output: Prints messages to the Developer Console indicating which GUI was enabled.*
Updated files
v1
حلو بس اذا لاعب مات يختفي Gui

Changes:

  1. 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.
  2. 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.
  3. onCharacterAdded Function:
    • This function now handles enabling the activeGui when the character loads (initially or after respawning).
    • It finds the Humanoid within the character.
    • It connects a function to the Humanoid.Died event.
    • When Humanoid.Died fires, the connected function runs, setting activeGui.Enabled = false.
  4. Event Connections:
    • The script now connects the onCharacterAdded function to the LocalPlayer.CharacterAdded event. This ensures the logic runs every time the player respawns.
    • It also checks if LocalPlayer.Character already exists when the script first runs and calls onCharacterAdded immediately if it does.
  5. Cleanup (Optional but Recommended): Added character.Destroying:Connect to disconnect the .Died event listener when the character is about to be destroyed, preventing potential memory issues.
Updated files
v2
سكربت لا يعمل في نحاية اذا لاعب مات يرجع سكربت

حسنًا، يبدو أن المشكلة تكمن في كيفية إعادة تمكين الواجهة الرسومية (GUI) بعد عودة اللاعب للحياة (Respawn).

السكريبت السابق كان يجب أن يعمل بشكل صحيح، لكن دعنا نقم ببعض التحسينات ونضيف المزيد من التأكيدات لضمان عمله في كل مرة يعود فيها اللاعب.

النقاط الرئيسية للتأكد منها:

  1. ResetOnSpawn: تأكد تمامًا من أن خاصية ResetOnSpawn لكل من Gui1 و Gui2 معطلة (false) في نافذة الخصائص (Properties) داخل Roblox Studio. هذا مهم جدًا حتى لا يقوم Roblox بإعادة تمكين الواجهة تلقائيًا عند العودة للحياة. السكربت يحاول تعطيلها، لكن من الأفضل التأكد منها في المحرر.
  2. أسماء الواجهات: تأكد 100% من أن الأسماء Gui1 و Gui2 في السكربت مطابقة تمامًا لأسماء الـ ScreenGui الموجودة داخل StarterGui. أي خطأ إملائي سيمنع السكربت من العثور عليها.
  3. مكان السكربت: تأكد من أن هذا LocalScript موجود داخل StarterPlayer -> StarterPlayerScripts.
  4. لا توجد أخطاء: راقب نافذة المخرجات (Output) في Roblox Studio بحثًا عن أي رسائل خطأ باللون الأحمر قد تشير إلى مشكلة في السكربت.

السكريبت المحسن:

سنستخدم نفس المنطق الأساسي ولكن مع تنظيم أفضل للاتصالات بالأحداث وإضافة المزيد من رسائل الطباعة للمساعدة في تتبع ما يحدث.

ما الجديد في هذا السكربت:

  1. المزيد من الطباعة (print): تمت إضافة المزيد من رسائل print لمساعدتك على رؤية ما يفعله السكربت خطوة بخطوة في نافذة المخرجات (Output). هذا سيساعد في تحديد مكان المشكلة إذا استمرت.
  2. فصل الاتصال السابق (diedConnection:Disconnect()): قبل توصيل حدث humanoid.Died لشخصية جديدة، نتأكد من فصل أي اتصال قديم بنفس الحدث. هذا يمنع وجود اتصالات متعددة غير ضرورية.
  3. التحقق من وجود الواجهات: يتم التحقق من وجود Gui1 و Gui2 في البداية وإصدار تحذير إذا لم يتم العثور عليهما.
  4. تنظيف إضافي: تمت إضافة تنظيف للاتصالات عند تدمير الشخصية وعند مغادرة اللاعب للعبة.

جرب هذا السكربت وتأكد من مراجعة النقاط الأربعة المذكورة في بداية الإجابة (خاصة ResetOnSpawn وأسماء الواجهات). راقب نافذة المخرجات (Output) بعناية عند اختبار اللعبة، خاصة عند الموت والعودة للحياة.

Updated files
v3