📌  相关文章
📜  如果触摸了某个部分,如何获得玩家 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:58.491000             🧑  作者: Mango

代码示例1
local Players = game:GetService("Players")
local TouchPart = workspace["Part"] -- assign a part to it

TouchPart.Touched:Connect(function(touched)
    if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
        local Player = Players:GetPlayerFromCharacter(touched.Parent)
        if Player then
            -- do something here
        end
    end
end)