local Hitbox = script.Parent
local Players = game.Players
Hitbox.Touched:Connect(function(hit)
local character = hit:FindFirstAncestorOfClass("Model")
if character then
local player = Players:GetPlayerFromCharacter(character)
if player then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
-- do action
end
end
end
end)
参考
https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerFromCharacter