of     1   

pwnion
#223894855Saturday, August 19, 2017 12:28 AM GMT

I'm using triggers in my game that affect the player by inserting localscripts and/or removing them. How do I get the player from touching a part?
hollowtommy221
#223894987Saturday, August 19, 2017 12:31 AM GMT

You could use this script.Parent.Touched:connect(function(touch) local human = touch.Parent:FindFirstChild("Humanoid") if human then local char = human.Parent local player = game.Players:GetPlayerFromCharacter(char) end end)
pwnion
#223895005Saturday, August 19, 2017 12:31 AM GMT

script.Parent.Touched:connect(function() --I can't do anything here since idk how to get the player end)
Rovert_Entertainment
#223895042Saturday, August 19, 2017 12:32 AM GMT

I think this? (in the part) script.Parent.Touched:connect(function(hit) if hit.Parent.Humanoid ~= nil then --do stuff with him end end)
hollowtommy221
#223895045Saturday, August 19, 2017 12:32 AM GMT

Use the script I posted. script.Parent.Touched:connect(function(touch) local human = touch.Parent:FindFirstChild("Humanoid") if human then local char = human.Parent local player = game.Players:GetPlayerFromCharacter(char) end end)
pwnion
#223895051Saturday, August 19, 2017 12:32 AM GMT

My bad I was a little impatient there and I thought people might've not understood the question.
Unsubtleties
#223895068Saturday, August 19, 2017 12:33 AM GMT

@hollowtommy221 What are all the variables for? Just assign a variable to the result of GetPlayerFromCharacter; if it returns nil, then don't do anything.
pwnion
#223895097Saturday, August 19, 2017 12:34 AM GMT

Thanks hollowtommy221!
hollowtommy221
#223895108Saturday, August 19, 2017 12:34 AM GMT

@Unsubtleties IDK. I just typed it without studio for a quick answer.
nothingguy123
#223895155Saturday, August 19, 2017 12:35 AM GMT

script.parent.Touched:connect(function(whateveryouwanthereitdoesntmatter) local player = whateveryouwantitdoesntmatter.parent end)
pwnion
#223895157Saturday, August 19, 2017 12:35 AM GMT

Wouldn't this be the same thing? script.Parent.Touched:connect(function(touch) local char = touch.Parent if char then local player = game.Players:GetPlayerFromCharacter(char) end end)
Unsubtleties
#223895193Saturday, August 19, 2017 12:36 AM GMT

No. "if char then" would also be entirely useless in that situation. You would want to check for player, not char.
pwnion
#223895199Saturday, August 19, 2017 12:36 AM GMT

Ahhh everybody's talking at once it makes my replies seem incoherent
nothingguy123
#223895243Saturday, August 19, 2017 12:37 AM GMT

What specific part of the player are you looking for? or are you just testing to see if it is a player?
pwnion
#223895252Saturday, August 19, 2017 12:37 AM GMT

script.Parent.Touched:connect(function(touch) local char = touch.Parent local player = game.Players:GetPlayerFromCharacter(char) end) This?
hollowtommy221
#223895298Saturday, August 19, 2017 12:38 AM GMT

That works too.
pwnion
#223895301Saturday, August 19, 2017 12:38 AM GMT

I'm just trying to get the player so I can insert localscripts.
Unsubtleties
#223895351Saturday, August 19, 2017 12:39 AM GMT

Just use the Touched event locally then.
nothingguy123
#223895501Saturday, August 19, 2017 12:42 AM GMT

yes

    of     1