Hey, I'm trying to make a script where if you touched a part during a round in my game, then you are supposed to teleport to the lobby. All this works but not the part where I try to award the player. When one player touch the part he gets 2 wins and not 1. Also I'm trying to do so whoever touches the part in like 30 seconds should get the win. So what have I done wrong here?
local teleportValue = game.ReplicatedStorage.Game:FindFirstChild("TeleportValue")
local module = require(game.ServerScriptService:FindFirstChild("MainModule"))
local gamefolder = game.ReplicatedStorage.Game
local status = gamefolder.Status
db = true
db2 = true
local PlayersThatTeleported = {}
script.Parent.Touched:Connect(function(hit)
hit.Parent:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(Vector3.new(95.27, 629.95, -78.735))
wait()
local human = hit.Parent:FindFirstChild("Humanoid")
if human ~= nil then
local char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local lb = player:FindFirstChild("leaderstats")
local AlreadyInTable = false
for _,OtherPlayer in next,PlayersThatTeleported do
if OtherPlayer == player then
AlreadyInTable = true
end
end
if not AlreadyInTable then
table.insert(PlayersThatTeleported,player)
end
if PlayersThatTeleported[1] == player and db == true then
db = false
for i,v in pairs(game.Players:GetChildren()) do
lb.Bits.Value = lb.Bits.Value +20
lb.Wins.Value = lb.Wins.Value +1
game.ReplicatedStorage.Remotes.PlayerWins:FireAllClients(v)
end
end
if PlayersThatTeleported[2] == player and db2 == true then
db2 = false
for i,v in pairs(game.Players:GetChildren()) do
lb.Bits.Value = lb.Bits.Value +20
lb.Wins.Value = lb.Wins.Value +1
game.ReplicatedStorage.Remotes.PlayerWins:FireAllClients(v)
end
end
end
end)
Sorry if this could be confusing but if you would like to help me I would be very happy! Thanks, Xsodar
