我最近遇到了麻烦,当我试图在一个数组中添加一个玩家时,如果一个部分被触摸了,但我似乎无法使其工作。
这是我的代码:
playerWin = {}
game.Workspace.SharkSurvival.givewin.Touched:Connect(function(TouchedPart)
if TouchedPart.Parent:FindFirstChild("Humanoid") then
local Character = TouchedPart.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local AlreadyInTable = false
-- Now make sure the player isn't already in the array
for _,OtherPlayer in next,playerWin do
if OtherPlayer == Player then
AlreadyInTable = true
end
end
if not AlreadyInTable then
-- Add them to the array!
table.insert(playerWin,Player.Name)
end
end
end)
任何帮助都将不胜感激。
谢谢
我希望我数组中的第一个对象是触摸该部分的玩家。