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 » Scripting Helpers
Home Search
 

Re: How to find the player not the character onTouched

Previous Thread :: Next Thread 
qwertyhat is not online. qwertyhat
Joined: 06 Aug 2009
Total Posts: 116
26 Jul 2013 01:09 PM
I need to find the actual player and change a value in the player's leaderstats, I don't know how you do that. Now, I know this script won't work, it's just an example, but I need to know how to do this.

function onTouched(hit)
hit.leaderstats.points.Value = 1
end
script.Parent.Touched:connect(onTouched)
Report Abuse
MisterEpicSpaghetti is not online. MisterEpicSpaghetti
Joined: 20 Jul 2013
Total Posts: 123
26 Jul 2013 01:12 PM
script.Parent.Touched:connect(function(t)
if script.Parent.Touched:findFirstChild("Humanoid") then
Plyr = script.Parent.Touched.Name
Player = game.Players:findFirstChild(Plyr)
Player.leaderstats.points.Value = Player.leaderstats.points.Value
end
end)
Report Abuse
MisterEpicSpaghetti is not online. MisterEpicSpaghetti
Joined: 20 Jul 2013
Total Posts: 123
26 Jul 2013 01:12 PM
Player.leaderstats.points.Value = Player.leaderstats.points.Value +1
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
26 Jul 2013 01:13 PM
if you have the character, it's easy to get the player

local plyr = game.Players[char.Name]
Report Abuse
baheeg is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
26 Jul 2013 01:25 PM
[ Content Deleted ]
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
26 Jul 2013 01:26 PM
@Roy: game.Players:GetPlayerFromCharacter(character)

USE THE DAMN API
Report Abuse
baheeg is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
26 Jul 2013 01:27 PM
[ Content Deleted ]
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
26 Jul 2013 01:27 PM
it's to hard to remember the names :3
Report Abuse
qwertyhat is not online. qwertyhat
Joined: 06 Aug 2009
Total Posts: 116
26 Jul 2013 01:32 PM
Ok thanks.
Report Abuse
Hibobb is not online. Hibobb
Joined: 18 Apr 2010
Total Posts: 2146
26 Jul 2013 01:53 PM
Isn't :GetPlayerFromCharacter also something you could use?
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
26 Jul 2013 01:54 PM
nope because my way is superior and that should never ever be used again
Report Abuse
Hibobb is not online. Hibobb
Joined: 18 Apr 2010
Total Posts: 2146
26 Jul 2013 01:58 PM
Alright then
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
26 Jul 2013 01:59 PM
He's lying

use the damn api
Report Abuse
Hibobb is not online. Hibobb
Joined: 18 Apr 2010
Total Posts: 2146
26 Jul 2013 01:59 PM
api?
Report Abuse
tdog158 is not online. tdog158
Joined: 08 Jul 2008
Total Posts: 5413
26 Jul 2013 02:00 PM
just use :GetPlayerFromCharacter( character )
Report Abuse
stroudie is not online. stroudie
Joined: 28 Nov 2008
Total Posts: 2556
26 Jul 2013 02:04 PM
GetPlayerFromCharacter takes up about as much space, or more, and will only be a superior choice in a few cases.

I think i'll stick with game.Players:FindFirstChild(char.Name) for now.
Report Abuse
tdog158 is not online. tdog158
Joined: 08 Jul 2008
Total Posts: 5413
26 Jul 2013 02:09 PM
Alright lol. Not the best habit, but it's your code.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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