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
 

Why does GetPlayerFromCharacter never work for me?

Previous Thread :: Next Thread 
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
05 Jun 2013 08:29 PM
in this script when the player touches a brick it should change their laps value to 1 and their gui text to 1/1. It changes the laps value to one which is inside the character's model but never the gui text. Output always tells me that "GetPlayerFromCharacter isn't a member of Model." Also there is an extra parent in the script as opposed to the usual because there is a morph inside the person's model and generally the morph is what touches the brick. However I put in an if statement to make sure that the touched part's Parent's Parent is the player's model itself. It is and the if statement and the prints after if function perfectly. here is the script:

function onTouched(part)
print("touched")
if part.Parent.Parent.ClassName == 'Model' then
local q = part.Parent.Parent
print("q is correct")
if q.Laps.Value == 0.75 then
q.Laps.Value = 1
print(q.Name)
yu = q:GetPlayerFromCharacter(part.Parent.Parent) --output has a problem here
print(yu.Name)
yu.PlayerGui.ScreenGui.Laps.Text = "1/1"
end
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
05 Jun 2013 08:31 PM
You're using one too many parents each time.

script.Parent.Touched:connect(function(Player)
Player = game.Players:GetPlayerFromCharacter(Player.Parent)
if(Player)then
-- Stuff with Player
end
end)
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
05 Jun 2013 08:38 PM
I'll try your script out for curiosity but I said I was using those parents because the part that touches the brick is inside a model inside the character's model because they're using a morph. And the Laps value changes to 1 like it's supposed to so if that was the problem it wouldn't make sense why that worked.
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