The 2 players usernames are stored as string values from other scripts.
I don’t know what the issue is, since no errors or warnings are shown in the output.
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local serverScriptService = game:GetService("ServerScriptService")
local folder = Workspace["Fight Request Pads Set 1"]
local value1 = folder["Fight Request Pad 1"].Value.Value
local value2 = folder["Fight Request Pad 2"].Value.Value
local fighting = Workspace["Fighting Map 1"].Value
fighting:GetPropertyChangedSignal("Value"):Connect(function()
if fighting.Value == true then
local player1 = Players:FindFirstChild(value1)
local player2 = Players:FindFirstChild(value2)
local scriptsFolder = serverScriptService["Fight Requests Managers"]["Set 1"]
if player1 and player2 and player1.Character and player2.Character then
local rootPart1 = player1.Character:FindFirstChild("HumanoidRootPart")
local rootPart2 = player2.Character:FindFirstChild("HumanoidRootPart")
local spawnFolder = Workspace["Fighting Map 1"]["Spawn Locations"]
local spawnParts = spawnFolder:GetChildren()
-- Randomly select two different spawn points
local randomSpawn1 = spawnParts[math.random(1, #spawnParts)]
local randomSpawn2 = spawnParts[math.random(1, #spawnParts)]
-- Ensure players don't spawn at the same location
while randomSpawn1 == randomSpawn2 do
randomSpawn2 = spawnParts[math.random(1, #spawnParts)]
end
rootPart1.CFrame = randomSpawn1.CFrame
rootPart2.CFrame = randomSpawn2.CFrame
local humanoid1 = player1.Character:FindFirstChild("Humanoid")
local humanoid2 = player2.Character:FindFirstChild("Humanoid")
humanoid1.HealthChanged:Connect(function()
if humanoid1.Health == 0 or humanoid2.Health == 0 then
rootPart1.CFrame = Workspace.SpawnLocation.CFrame
rootPart2.CFrame = Workspace.SpawnLocation.CFrame
fighting.Value = false
end
end)
end
end
end)