3xpert
|
  |
| Joined: 11 May 2013 |
| Total Posts: 1513 |
|
|
| 16 Jul 2013 02:13 PM |
function onTouched(hit) chr = hit.Parent:GetPlayerFromCharacter() if chr.TeamColor == BrickColor.new("Bright red") and chr.Character.Humanoid.Health ~= 0 then script.Parent.BrickColor = BrickColor.new("Bright red") end end script.Parent.Touched:connect(onTouched)
It's not working, and I'm pretty sure that it's because I'm using the :GetPlayerFromCharacter() function wrong. Can someone help?
NOTE : Normal script inside of regular part. |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 02:14 PM |
Try
chr = game.Players[hit.Parent.Name] if not char then return end |
|
|
| Report Abuse |
|
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
|
| 16 Jul 2013 02:16 PM |
Roy...
chr = game.Players[hit.Parent.Name] if not chr then return end |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 02:18 PM |
| I'm so used to writing it as char, not chr, my bad |
|
|
| Report Abuse |
|
|
3xpert
|
  |
| Joined: 11 May 2013 |
| Total Posts: 1513 |
|
|
| 16 Jul 2013 02:18 PM |
Where do I place the if not chr then return end?
Thanks for the help guys... :) |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 02:19 PM |
| right after you declare chr |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 02:20 PM |
3xpert
switch it with this part:
chr = hit.Parent:GetPlayerFromCharacter() |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 02:21 PM |
OH wait nvm nvm nvm DUN STOP STOOPP Dun do wut I said. kthx
[[FLOOODCHECKK]] |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 16 Jul 2013 02:23 PM |
function onTouched(hit) chr = game.Players:GetPlayerFromCharacter(hit.Parent) if chr and chr.TeamColor == BrickColor.new("Bright red") and chr.Character.Humanoid.Health ~= 0 then script.Parent.BrickColor = BrickColor.new("Bright red") end end script.Parent.Touched:connect(onTouched)
You didn't properly use GetPlayerFromCharacter, and you didn't check to see if 'chr' existed. GetPlayerFromCharacter returns the Player or nil. |
|
|
| Report Abuse |
|
|
3xpert
|
  |
| Joined: 11 May 2013 |
| Total Posts: 1513 |
|
| |
|