I've tried debounce, it didn't work. Whenever a player touches the win area, it's meant to give them the amount of coins the person who edited the script of what they wanted and 1 win. It keeps giving double or even MORE than double amount. Please, someone fix my script.
local spawns = {
game.Workspace.Lobby.lobbySpawns.lobbySpawn1.CFrame,
game.Workspace.Lobby.lobbySpawns.lobbySpawn2.CFrame
}
script.Parent.Touched:Connect(function(plr)
local player = game:GetService("Players"):GetPlayerFromCharacter(plr.Parent)
local debounce = player.Settings.Won.Value
if debounce == true then
delay(0, function()
player.leaderstats.Minicoins.Value = player.leaderstats.Minicoins.Value + 15
player.leaderstats.MinigameWins.Value = player.leaderstats.MinigameWins.Value + 1
end)
local rootPart = plr.Parent:FindFirstChild("HumanoidRootPart")
rootPart.CFrame = spawns[math.random(1, #spawns)]
debounce = false
end
end)

1 comment
Is it because there is not wait in between awarding, therefore whenever the player might want to move off the script keep detecting?