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: I need help with this InsertService script

Previous Thread :: Next Thread 
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 02:16 PM
This script was given to me from someone who posted on my other thread with insert service, but it appears to not work. I don't know why, Output gave me nothing. Here's the script:

local Player = game.Players.LocalPlayer
local gun = game:GetService("InsertService"):LoadAsset(108124632)
local LSVALUE = "Cash" --the name of the value in the ls you're comparing your cost with,

script.Parent.Text = script.Parent.ItemName.Value..": "..script.Parent.Cost.Value.." "..script.Parent.Currency.Value

script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats[LSVALUE].Value >= script.Parent.Cost.Value then
Player.leaderstats[LSVALUE].Value = Player.leaderstats[LSVALUE].Value - script.Parent.Cost.Value
gun:Clone().Parent=Player.Backpack
gun:Clone().Parent=Player.StarterGear
end
end
end)
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 04:37 PM
bump
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 07:33 PM
help
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
06 Mar 2013 07:35 PM
gun.Parent = Workspace
gun:Clone().Parent=Player.Backpack
gun:Clone().Parent=Player.StarterGear

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 08:45 PM
Still, it doesn't work.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
06 Mar 2013 08:50 PM
Using insertservice will give you a model. You'd have to extract it from the model.

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
06 Mar 2013 08:51 PM
function unZip(model,parent)
for _,v in pairs(model:GetChildren()) do
v.Parent = parent
end
model:Destroy()

ID = 1337

insert = game:GetService("InsertService"):LoadAsset(ID)
insert.Parent = workspace
unZip(insert,workspace)

:D

~ Failure is the road to success ~
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
06 Mar 2013 08:52 PM
dang it i've been forgetting ends like cray cray

function unZip(model,parent)
for _,v in pairs(model:GetChildren()) do
v.Parent = parent
end
model:Destroy()
end

ID = 1337

insert = game:GetService("InsertService"):LoadAsset(ID)
insert.Parent = workspace
unZip(insert,workspace)

~ Failure is the road to success ~
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 08:53 PM
Well it's a tool. How do I do that? Do I put this:
gun.Parent = Workspace
gun.Python:clone().Parent = Player.Backpack
gun.Python:clone().Parent = Player.StarterGear
gun:remove()
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
06 Mar 2013 08:54 PM
Yes, if that's the name inside of the model. Though Usering's function does look nifty.

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 08:56 PM
Yes, it does, but how do I put a line in it that makes sure you have enough cash and takes it away?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
06 Mar 2013 08:56 PM
You already have that, just use his function.

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 09:03 PM
I still am wondering, where does it go? Beginning, End, or Somewhere in the middle?
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 09:40 PM
Help? Where does Usering's script go in mine?
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
06 Mar 2013 10:19 PM
Please help!
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
06 Mar 2013 10:22 PM
Put his function before yours, call it when you need to.

 
¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
07 Mar 2013 06:29 AM
Is this what it should be like? (Just a question, does it always have to be inserted into Workspace? I want to insert it into Lighting, where it unZips, so I don't have to worry about lag.)


function unZip(model,parent)
for _,v in pairs(model:GetChildren()) do
v.Parent = parent
end
model:Destroy()
end

ID = 108124632

insert = game:GetService("InsertService"):LoadAsset(ID)
insert.Parent = lighting
unZip(insert,lighting)


local Player = game.Players.LocalPlayer
local LSVALUE = "Cash" --the name of the value in the ls you're comparing your cost with,

script.Parent.Text = script.Parent.ItemName.Value..": "..script.Parent.Cost.Value.." "..script.Parent.Currency.Value

script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats[LSVALUE].Value >= script.Parent.Cost.Value then
Player.leaderstats[LSVALUE].Value = Player.leaderstats[LSVALUE].Value - script.Parent.Cost.Value
unZip()
game.Lighting.Python.Parent = Player.Backpack
game.Lighting.Python:clone().Parent = Player.StarterGear
end
end
end)
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
07 Mar 2013 06:32 AM
Or would it be like this:

function unZip(model,parent)
for _,v in pairs(model:GetChildren()) do
v.Parent = parent
end
model:Destroy()
end

ID = 108124632

insert = game:GetService("InsertService"):LoadAsset(ID)


local Player = game.Players.LocalPlayer
local LSVALUE = "Cash" --the name of the value in the ls you're comparing your cost with,

script.Parent.Text = script.Parent.ItemName.Value..": "..script.Parent.Cost.Value.." "..script.Parent.Currency.Value

script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats[LSVALUE].Value >= script.Parent.Cost.Value then
Player.leaderstats[LSVALUE].Value = Player.leaderstats[LSVALUE].Value - script.Parent.Cost.Value
insert.Parent = lighting
unZip(insert,lighting)
game.Lighting.Python.Parent = Player.Backpack
game.Lighting.Python:clone().Parent = Player.StarterGear
end
end
end)
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
07 Mar 2013 09:40 AM
you can only forget the game prefix on workspace.


function unZip(model,parent)
for _,v in pairs(model:GetChildren()) do
v.Parent = parent
end
model:Destroy()
end

ID = 108124632

insert = game:GetService("InsertService"):LoadAsset(ID)


local Player = game.Players.LocalPlayer
local LSVALUE = "Cash" --the name of the value in the ls you're comparing your cost with,

script.Parent.Text = script.Parent.ItemName.Value..": "..script.Parent.Cost.Value.." "..script.Parent.Currency.Value

script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats[LSVALUE].Value >= script.Parent.Cost.Value then
Player.leaderstats[LSVALUE].Value = Player.leaderstats[LSVALUE].Value - script.Parent.Cost.Value
unZip(insert,game.Lighting)
game.Lighting.Python:clone().Parent = Player.StarterGear,Player.Backpack
end
end
end)

~ Failure is the road to success ~
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
07 Mar 2013 03:45 PM
Yeaaaahhhh buddy!
It works!
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
07 Mar 2013 03:51 PM
Thanks Usering and KnightmareXD!
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
07 Mar 2013 07:56 PM
Now it broke again!
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
07 Mar 2013 08:00 PM
Try putting the LoadAsset part inside of the function.

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
07 Mar 2013 08:03 PM
It worked before, and it just stopped working. Maybe because of the update or I'm using recently updated/made models to be inserted.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
07 Mar 2013 08:14 PM
Like I said, try doing this:

function unZip(model,parent)
for _,v in pairs(model:GetChildren()) do
v.Parent = parent
end
model:Destroy()
end
ID = 108124632
local Player = game.Players.LocalPlayer
local LSVALUE = "Cash" --the name of the value in the ls you're comparing your cost with,
script.Parent.Text = script.Parent.ItemName.Value..": "..script.Parent.Cost.Value.." "..script.Parent.Currency.Value
script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats[LSVALUE].Value ​>= script.Parent.Cost.Value then
Player.leaderstats[LSVALUE].Value = Player.leaderstats[LSVALUE].Value - script.Parent.Cost.Value
insert = game:GetService("InsertService"):LoadAsset(ID)
unZip(insert,game.Lighting)
game.Lighting.Python:clone().Parent = Player.StarterGear,Player.Backpack
end
end
end)

?

¤ ¤ † K M <( •д• )> X D † ¤ ¤
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