|
| 31 Aug 2014 09:30 PM |
So I've been working through flaws in my script, which I'm happy because It stretched my knowledge. But I still have a problem
So Theres a part that when touched it enables a script in the players backpack. then it disables it again
script.Parent.Touched:connect(function(hit) hit.Backpack.Cam.Disabled = false wait(6) hit.Backpack.Cam.Disabled = true end)
(the reason I put backpack instead of starterpack is because players don't have a starterpack, but a backpack)
the output says:
22:26:00.868 - Backpack is not a valid member of Part 22:26:00.868 - Script 'Workspace.Part.Script', Line 2 22:26:00.869 - Stack End 22:26:00.869 - Disconnected event because of exception
|
|
|
| Report Abuse |
|
|
|
| 31 Aug 2014 09:31 PM |
Extra Tip:
When I was testing it I realized there was Player1 in workspace (which had the model of the person itself) and a Player1 in Players (with the backpack,startergui, etc)
Hope that helps... |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 31 Aug 2014 09:41 PM |
"hit" represents the part that touched the other part, so suppose the character's leg touches it. You are trying to locate the Backpack under the leg. So what you need to do instead is take "hit", locate the character it belongs to, and then use GetPlayerFromCharacter() (or there's another way that I'll show you in an example) to locate the player, and then the backpack can be accessed from there. You will also have to check if the part that touches it belongs to a character.
So, try this instead
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then Players[hit.Parent.Name].Backpack.Cam.Disabled = false -- locating the Player by using the players's name instead of the GetPlayerFromCharacter method. Either should be fine. wait(6) Players[hit.Parent.Name].Backpack.Cam.Disabled = true end end)
Remember to use proper whitespace, since the ROBLOX forum isn't too friendly towards scripters. |
|
|
| Report Abuse |
|
|
|
| 01 Sep 2014 09:06 AM |
Didn't exactly work, but luckily it came up with an output
10:04:55.402 - Workspace.Part.Script:3: attempt to index global 'Players' (a nil value) 10:04:55.402 - Stack Begin 10:04:55.403 - Script 'Workspace.Part.Script', Line 3 10:04:55.403 - Stack End 10:04:55.403 - Disconnected event because of exception
Also, Thanks for explaining me the problem about hit, not just giving me the script out of nowhere
|
|
|
| Report Abuse |
|
|