You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to open a specific Gui to a Player
Script1:
local MobModule = require(script.Mobs)
local SpawnBalloon = game.ReplicatedStorage:WaitForChild("SpawnBalloon")
local SpawnTower = game.ReplicatedStorage:WaitForChild("AddTower")
local Information = game.ReplicatedStorage:WaitForChild("MainGame"):WaitForChild("Information")
local GameStarted = game.ReplicatedStorage:WaitForChild("MainGame"):WaitForChild("GameStarted")
local Rounds = game.ReplicatedStorage:WaitForChild("MainGame"):WaitForChild("Rounds")
local OpenGui = game.ReplicatedStorage:WaitForChild("OpenGui")
local StartingCash = 100
local function GiveCash(Player, Amount)
Player.PlayerData.Cash.Value = Player.PlayerData.Cash.Value + Amount
end
local function SetHealth(Char)
local Hum = Char:FindFirstChildWhichIsA("Humanoid")
local GuiClone = game.ReplicatedStorage.HealthGui:Clone()
GuiClone.Parent = Char
--// Scripting HealthBar \\--
if Char.Name == "Base" then
GuiClone.MaxDistance = 350
GuiClone.Size = UDim2.new(20,0,5,0)
else
GuiClone.MaxDistance = 80
GuiClone.Size = UDim2.new(10,0,2.5,0)
end
local colorGreen = Color3.fromRGB(0, 255, 0)
local colorRed = Color3.fromRGB(255, 0, 0)
local Health = Hum.Health
local MaxHwalth = Hum.MaxHealth
local Percentage = Health / MaxHwalth
GuiClone.TextLabel.Text = GuiClone.Parent.Name..": "..Health.."/"..MaxHwalth
GuiClone.Health.Size = UDim2.new(Percentage, 0, 1 ,0)
GuiClone.Health.BackgroundColor3 = colorRed:Lerp(colorGreen, Health / MaxHwalth)
Hum.HealthChanged:Connect(function()
local Health = Hum.Health
local MaxHwalth = Hum.MaxHealth
local Percentage = Health / MaxHwalth
GuiClone.TextLabel.Text = GuiClone.Parent.Name..": "..Health.."/"..MaxHwalth
GuiClone.Health.Size = UDim2.new(Percentage, 0, 1 ,0)
GuiClone.Health.BackgroundColor3 = colorRed:Lerp(colorGreen, Health / MaxHwalth)
end)
end
while wait() do
if #game.Players:GetPlayers() < 1 then
Information.Value = "Not Enough Players"
else
for i = 10,0,-1 do
Information.Value = "Game Starting In "..i
wait(1)
if i == 0 then
local RandomPlayer = game:GetService("Players"):GetChildren()[math.random(1,#game:GetService("Players"):GetChildren())]
print(RandomPlayer.Name)
for i, v in pairs(game.Players:GetPlayers()) do
GiveCash(v, StartingCash)
if v.Name == RandomPlayer.Name then
v.PlayerData.IsImposter.Value = true
OpenGui:FireClient(v, v.PlayerGui:FindFirstChild("TowerGui"))
else
v.PlayerData.IsImposter.Value = false
OpenGui:FireClient(v, v.PlayerGui:FindFirstChild("BalloonGui"))
end
end
GameStarted.Value = true
workspace.Balloons.ChildAdded:Connect(function(Object)
coroutine.wrap(SetHealth)(Object)
end)
coroutine.wrap(SetHealth)(workspace.Base)
SpawnBalloon.OnServerEvent:Connect(function(Player, BalloonName)
MobModule.Spawm(BalloonName)
end)
end
end
break
end
end
Script: 2
local MoneyFrame = script.Parent.MoneyFrame
local Player = game.Players.LocalPlayer
local PlayerDataFolder = Player.PlayerData
while wait() do
MoneyFrame.TextLabel.Text = "Cash: "..PlayerDataFolder.Cash.Value
end
game.ReplicatedStorage.OpenGui.OnClientEvent:Connect(function(PLR, plrGui)
plrGui.Enabled = true
end)
Game Name: Bloons TDS X