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: Simple Script Help

Previous Thread :: Next Thread 
SpazzMan502 is not online. SpazzMan502
Joined: 01 Aug 2013
Total Posts: 2397
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
SpazzMan502 is not online. SpazzMan502
Joined: 01 Aug 2013
Total Posts: 2397
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 is not online. 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
SpazzMan502 is not online. SpazzMan502
Joined: 01 Aug 2013
Total Posts: 2397
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
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