generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Game Design
Home Search
 

Re: Get a player name and set it as a variable?

Previous Thread :: Next Thread 
prowler100 is not online. prowler100
Joined: 05 Dec 2009
Total Posts: 53
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 is not online. LuaLlama
Joined: 25 Jan 2014
Total Posts: 1123
04 Aug 2015 05:11 PM


game.Players[name].Character.Humanoid.Health = 0
Report Abuse
Drakles is not online. 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
prowler100 is not online. prowler100
Joined: 05 Dec 2009
Total Posts: 53
04 Aug 2015 05:58 PM
Thank you, both of you. That really helps.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image