Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR LUA

How to get a player if a part is touched

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)
Source by devforum.roblox.com #
 
PREVIOUS NEXT
Tagged: #How #player #part #touched
ADD COMMENT
Topic
Name
1+4 =