|
| 04 Aug 2015 05:00 PM |
Hope the title wasn't misleading. I'm new to scripting, just currently looking to experiment with code with my friends. I've looked and experimented different things (I tend to just piece together information when I want to try and learn) but I can't figure out how to set a variable as a player name when a block is touched or clicked.
I get the whole click detector and touch detector but I can't figure out how to set a variable to the name of a player so I could do, for example,
game.Workspace.name.Humanoid.Health = 0
with name being the variable containing player name. |
|
|
| Report Abuse |
|
|
LuaLlama
|
  |
| Joined: 25 Jan 2014 |
| Total Posts: 1123 |
|
|
| 04 Aug 2015 05:11 PM |
game.Players[name].Character.Humanoid.Health = 0 |
|
|
| Report Abuse |
|
|
Drakles
|
  |
| Joined: 19 Oct 2014 |
| Total Posts: 1066 |
|
|
| 04 Aug 2015 05:20 PM |
--\ Using the MouseClick event from a ClickDetector.
game.Workspace.Part.ClickDetector.MouseClick:connect(function(Player) Player.Character.Humanoid.Health = 0 end)
--\ Using the Touched event from a Part.
game.Workspace.Part.Touched:connect(function(Hit) if Hit:FindFirstChild("Humanoid") then local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) Player.Character.Humanoid.Health = 0 end end)
If not you, then who? If not now, then when? |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 05:58 PM |
| Thank you, both of you. That really helps. |
|
|
| Report Abuse |
|
|