So what I have been trying to do lately is access the Player’s character from the model in workspace when a part is touched.
Basically this:
script.Parent.touched:Connect(function(hit)
end)
So I tried looking for solutions on how to access the character in the Player service, however I did not come across any. Only to access the model in workspace from the character.
Has anybody got the solution to this? I’m sure this is something basic that I might have missed. I’m fairly new to scripting.
Part.Touched:Connect(function(Hit)
local Model = Hit:FindFirstAncestorWhichIsA("Model")
local Humanoid = Model:FindFirstChildWhichIsA("Humanoid")
if Model and Humanoid then
...
end
end)
script.Parent.touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
if humanoid then
local character = humanoid.Parent
local player = game.Players:GetPlayerFromCharacter(character)
end
end)