|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|