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: Would this work?

Previous Thread :: Next Thread 
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
22 Mar 2014 07:12 PM
This is my first time working with SaveInstance and LoadInstance. So please help me out here, I'm trying to get this script to load a car into another model when a player joins.

game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
if player.TeamColor == BrickColor.new("Bright green") then
game.Lighting.Startinggrid.Cars.Green:Destroy()
player:LoadInstance("Car").Name = "Green"
player:LoadInstance("Car").Parent = game.Lighting.Startinggrid.Cars
end
end
end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Mar 2014 07:13 PM
Take out if player:WaitFor--
And change to

player:WaitForDataReady()--will wait until data is ready,no ifs

And then

if player:LoadInstance("Car")~=nil then
Report Abuse
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
22 Mar 2014 07:15 PM
Changed that, so the rest of it should work??
Report Abuse
BlackBucketBoy is not online. BlackBucketBoy
Joined: 22 Jul 2011
Total Posts: 3230
22 Mar 2014 07:17 PM
change

player:LoadInstance("Car").Name = "Green"
player:LoadInstance("Car").Parent = game.Lighting.Startinggrid.Cars

to

local car = player:LoadInstance("Car")
car.Name = "Green"
car.Parent = game.Lighting.Startingrid.Cars
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
22 Mar 2014 07:18 PM
@Island,
Actually doing it how he did, with WaitForDataReady (if statement), would work perfectly fine and may be seen as better. The method mentioned will "pause" the script until their data is ready or until a certain amount of time has elapsed, regardless of whether or not their data is ready.
Report Abuse
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
22 Mar 2014 08:20 PM
it doesn't clone the model into the game...
Report Abuse
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
22 Mar 2014 08:26 PM
nvm, it does
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