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: GetPlayerFromCharacter()

Previous Thread :: Next Thread 
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
13 Jul 2014 02:48 AM
I have seen the wiki and related threads to this topic but this one is different.
I need to call the pathway to the character but I don't know how I can!?
Be in mind this is in a server script, so LocalPlayer won't work.

local Player = game:GetService("Players"):GetPlayerFromCharacter()--What Should go between the parenthesis ??

Player.CharacterAdded:connect(function(character)
Player.Character.Humanoid.Seated:connect(function()
end)
end)
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
13 Jul 2014 02:52 AM
An example would be something like,
game.Workspace.Part.Touched:connect(function(Toucher)
if Toucher.Parent:FindFirstChild("Humanoid") then
Player = game.Players:GetPlayerFromCharacter(Toucher.Parent.Name)
print(Player.Name)
end
end)
--The .Name may not be necessary in the parameters in :GetPlayerFromCharacter().
Report Abuse
CodyTheScriptingKid is not online. CodyTheScriptingKid
Joined: 15 Apr 2013
Total Posts: 8
13 Jul 2014 03:01 AM
.Name shouldn't be there, just "Toucher.Parent" as that is the character.
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
13 Jul 2014 03:05 AM
... Do you see a touch event in my code,Nope I don't see one.

Anony I know how it works but in my script above I don't think there is a way to get the pathway of the character.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
13 Jul 2014 03:06 AM
Do you mean how to get the character from the player? You didn't state the problem very clearly, if so: Game.Players.Player.Character.Head:Destroy()
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
13 Jul 2014 03:15 AM
Anony the GetPlaerFromChar argument is an object value
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
13 Jul 2014 08:36 AM
@CodyTheBuildingKid

I know how to use it but from the example I wrote above there is no way to verify the character from the limited info given above unless you have an idea how.
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
13 Jul 2014 09:00 AM
game.Players:GetPlayerFromCharacter(PlayerVariableHere).Character
Please give us a more detailed explanation of what you're trying to do with the script.
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
13 Jul 2014 11:26 AM
local Player = game:GetService("Players"):GetPlayerFromCharacter()

Player.CharacterAdded:connect(function(character)
Player.Character.Humanoid.Seated:connect(function()
for i,v in pairs(Workspace:GetChildren()) do
if v.Name == "Car" then
if v.VehicleSeat.Throttle == 1 or 0 then
for e,z in pairs (v:GetChildren()) do
if z.Name == "Brake" then
z.BrickColor = BrickColor.new("Bright red")
elseif v.VehicleSeat.Throttle == -1 then
z.BrickColor = BrickColor.new("Really red")
end
end
end
end
end
end)
end)
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
13 Jul 2014 01:03 PM
No-one has a clue?
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
13 Jul 2014 01:57 PM
You have to have a character to get the player... If you're trying to make this for all players:

Game.Players.PlayerAdded:connect(function(Player)

Player.CharacterAdded:connect(function(character)
Player.Character.Humanoid.Seated:connect(function()
for i,v in pairs(Workspace:GetChildren()) do
if v.Name == "Car" then
if v.VehicleSeat.Throttle == 1 or v.VehicleSeat.Throttle == 0 then
for e,z in pairs (v:GetChildren()) do
if z.Name == "Brake" then
z.BrickColor = BrickColor.new("Bright red")
elseif v.VehicleSeat.Throttle == -1 then
z.BrickColor = BrickColor.new("Really red")
end
end
end
end
end
end)
end)

end)
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
13 Jul 2014 02:55 PM
Thanks mate!
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