我做了一个这样的脚本 这不是本地脚本
local folder = workspace.Coins
local players = game:GetService("Players")
function playerSpawned(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local coins = Instance.new("IntValue", leaderstats)
coins.Name = "Coins"
coins.Value = 100
for i, objects in pairs(folder:GetChildren()) do
local button = Instance.new("ClickDetector")
button.Parent = objects
objects.ClickDetector.CursorIcon = "rbxassetid://7029597423"
objects.ClickDetector.MouseClick:Connect(function()
objects.ClickDetector.MaxActivationDistance = 0
objects.Transparency = 1
objects.CanCollide = false
coins.Value = coins.Value + 10
wait(10)
objects.ClickDetector.MaxActivationDistance = 300
objects.Transparency = 0
objects.CanCollide = true
end)
end
end
players.PlayerAdded:Connect(playerSpawned)
如何才能让一个玩家拿走一枚硬币,而另一位玩家则不会在排行榜中获得硬币?
将 for 循环移到函数之外