I want a forcefield to be given to the player at this point in the script
for x, player in pairs(players) do
local char = player.Character
if not char then
print(player.Name.." has no character!")
else
local humanoidrootpart = char.HumanoidRootPart
if not humanoidrootpart then
print(player.Name.." has no HumanoidRootPart!")
else
humanoidrootpart.CFrame = workspace.Lobby.SpawnLocation.CFrame + Vector3.new(0,3,0)
end
end
wait()
end
clonemap:Destroy()
end
and for it to be taken away at this part of the script
for x, player in pairs(players) do
local char = player.Character
if not char then
print(player.Name.." has no character!")
else
local humanoidrootpart = char.HumanoidRootPart
if not humanoidrootpart then
print(player.Name.." has no HumanoidRootPart!")
else
humanoidrootpart.CFrame = clonemap.Spawn.CFrame + Vector3.new(0,3,0)
end
end
wait()
end
here is the full script:
local rep = game:GetService("ReplicatedStorage")
local mapsfolder = game:GetService("Lighting"):WaitForChild("Maps")
local booleans = rep:WaitForChild("Booleans")
local variables = rep:WaitForChild("Variables")
local choice1 = variables:FindFirstChild("Choice1")
local choice2 = variables:FindFirstChild("Choice2")
local choice3 = variables:FindFirstChild("Choice3")
local winner = variables:FindFirstChild("Winner")
local timer = 10 --in seconds
while true do
while true do
local maps = mapsfolder:GetChildren()
choice1.Value = maps[math.random(1,#maps)]
table.remove(maps,table.find(maps,choice1.Value))
choice2.Value = maps[math.random(1,#maps)]
table.remove(maps,table.find(maps,choice2.Value))
choice3.Value = maps[math.random(1,#maps)]
table.remove(maps,table.find(maps,choice3.Value))
wait(1)
booleans:FindFirstChild("VotingSession").Value = true
wait(10)
booleans:FindFirstChild("RevealVotes").Value = true
wait(5)
booleans:FindFirstChild("VotingSession").Value = false
booleans:FindFirstChild("RevealVotes").Value = false
local chosenmap = winner.Value
if not winner.Value then
print("Something went wrong!")
break
end
local map = chosenmap.Value
local clonemap = map:Clone()
print("Getting map...")
wait(1)
print("Getting map spawn...")
if clonemap.Spawn then
print("Success!")
else
print("Task failed successfully")
wait()
print("Restarting...")
clonemap:Destroy()
break
end
clonemap.Parent = workspace
print("Getting players...")
local players = game:GetService("Players"):GetPlayers()
for x, player in pairs(players) do
local char = player.Character
if not char then
print(player.Name.." has no character!")
else
local humanoidrootpart = char.HumanoidRootPart
if not humanoidrootpart then
print(player.Name.." has no HumanoidRootPart!")
else
humanoidrootpart.CFrame = clonemap.Spawn.CFrame + Vector3.new(0,3,0)
end
end
wait()
end
for i = timer,0,-1 do
print(i)
wait(1)
end
for x, player in pairs(players) do
local char = player.Character
if not char then
print(player.Name.." has no character!")
else
local humanoidrootpart = char.HumanoidRootPart
if not humanoidrootpart then
print(player.Name.." has no HumanoidRootPart!")
else
humanoidrootpart.CFrame = workspace.Lobby.SpawnLocation.CFrame + Vector3.new(0,3,0)
end
end
wait()
end
clonemap:Destroy()
end
end
