Guest

Roblox Astral Script with Mana Loading Implementation

Nov 22nd, 2025
132
0
Never
Not a member of gistpad yet? Sign Up, it unlocks many cool features!
Lua 13.75 KB | Gaming | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local AstralEvent = ReplicatedStorage:WaitForChild("AstralEvent")
  3.  
  4. print("👻 Скрипт Астрала (с Маной) загружен")
  5.  
  6. -- === НАСТРОЙКА ЦЕНЫ ===
  7. local MANA_COST = 30 -- Должно совпадать с ModuleScript!
  8.  
  9. local activeBodies = {}
  10.  
  11. local function setGhostVisuals(char, isGhost)
  12. local transparency = isGhost and 0.6 or 0
  13. for _, part in pairs(char:GetDescendants()) do
  14. if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
  15. part.Transparency = transparency
  16. elseif part:IsA("Decal") then
  17. part.Transparency = transparency
  18. end
  19. end
  20. end
  21.  
  22. AstralEvent.OnServerEvent:Connect(function(player)
  23. local character = player.Character
  24. if not character then return end
  25.  
  26. local rootPart = character:FindFirstChild("HumanoidRootPart")
  27. local humanoid = character:FindFirstChild("Humanoid")
  28.  
  29. if activeBodies[player] then
  30. -- === ВЫХОД ИЗ АСТРАЛА (БЕСПЛАТНО) ===
  31. local oldBody = activeBodies[player]
  32.  
  33. if oldBody and oldBody:FindFirstChild("HumanoidRootPart") then
  34. rootPart.CFrame = oldBody.HumanoidRootPart.CFrame
  35. end
  36.  
  37. if oldBody then oldBody:Destroy() end
  38. activeBodies[player] = nil
  39. setGhostVisuals(character, false)
  40. local ff = character:FindFirstChild("AstralShield")
  41. if ff then ff:Destroy() end
  42. humanoid.DisplayName = player.DisplayName
  43.  
  44. else
  45. -- === ВХОД В АСТРАЛ (ПЛАТНО) ===
  46.  
  47. -- [СПИСАНИЕ МАНЫ]
  48. local currentMana = character:GetAttribute("Mana") or 0
  49. if currentMana < MANA_COST then return end -- Защита
  50. character:SetAttribute("Mana", currentMana - MANA_COST)
  51.  
  52. -- Логика входа
  53. character.Archivable = true
  54. local bodyClone = character:Clone()
  55. bodyClone.Name = "Body_" .. player.Name
  56. for _, obj in pairs(bodyClone:GetDescendants()) do
  57. if obj:IsA("Script") or obj:IsA("LocalScript") or obj:IsA("Tool") then obj:Destroy() end
  58. end
  59. for _, part in pairs(bodyClone:GetDescendants()) do
  60. if part:IsA("BasePart") then part.Anchored = true; part.CanCollide = false end
  61. end
  62.  
  63. bodyClone.Parent = workspace
  64. bodyClone:SetPrimaryPartCFrame(rootPart.CFrame)
  65. activeBodies[player] = bodyClone
  66.  
  67. setGhostVisuals(character, true)
  68. local ff = Instance.new("ForceField")
  69. ff.Name = "AstralShield"; ff.Visible = false; ff.Parent = character
  70. humanoid.DisplayName = "👻 Spirit"
  71. end
  72. end)
  73.  
  74. game.Players.PlayerRemoving:Connect(function(player)
  75. if activeBodies[player] then activeBodies[player]:Destroy() end
  76. end)
RAW Gist Data Copied