I am folowing this video. https://www.youtube.com/watch?v=vCpl5M_9mcQ&list=PLS-j30ccc9F-fQjfMfKQUvwbZmy49v-Js&index=4
and this https://www.youtube.com/watch?v=1MappXJ51Oo&list=PLsbxI7NIoTthI4KAXPMls60gwVkJbDEl1&index=2 Please help me my first time to try macing a game.
This is my Main script:
-- Dfine veriables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local MapsFolder =ServerStorage:WaitForChild("Maps")
local Status = ReplicatedStorage:WaitForChild("Status")
local GameLength = 50
-- Game loop
while true do
Status.Value = "Waiting for enough players"
repeat wait(1) until game.players.NumPlayers >= 2
Status.Value = "Intermission"
wait(10)
local plrs = {}
for i, player in pairs (game.Players:GetPlayers()) do
if player then
table.insert(plrs,player) -- Add each player into plrs table
end
end
wait(2)
local AvilableMaps = MapsFolder:GetChildren()
local ChosenMap = AvailableMaps[math.random(1,#AvilableMaps)]
Status.Value =ChosenMap.Name.." Chosen"
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent =workspace
-- Teleport players to the map
local SpawnPoint = ClonedMap:FindFirstChild("SpawnPoints")
if not SpawnPoint then
print ("SpawnPoint not found!")
end
local AvilableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
-- Teleport them
character:FindFirstChild("HumanoidRootPart").CFrame = AvilabeSpawnPoints[1].CFrame
table.remove(AvilableSpawnPoints,1)
--Give them a sword
local Sword = ServerStorage.Sword:Clone()
Sword.Parent = player.Backpack
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
--There is no character
if not player then
table.remove(plrs,i)
end
end
end
end
And this is the textlabel Local script:
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
script.Parent.Text =Status.Value
Status:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Text = Status.Value
end)
My stats script:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local bucks = Instance.new("IntValue")
bucks.Name = "Bucks"
bucks.Value = 0
bucks.Parent = leaderstats
end)
