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 » Scripters
Home Search
 

Re: quick help with strings

Previous Thread :: Next Thread 
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:02 PM
hi im trying to clone a weapon from serverstorage into the players backpack

i have a little function that fires onenter and it looks for the path of the weapon to clone via two stringvalues.

so these stringvalues have the name of two folders in serverstorage that the function goes through, they are called house and person.

heres how im trying to do it, but it's not working. any ideas?

game.ServerStorage:FindFirstChild(house):FindFirstChild(person):Clone().Parent = player.Backpack


Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:09 PM
help me you nuggets


Report Abuse
TaaRt is online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
03 Nov 2017 07:19 PM
house = the object
house.Value = property holding the value assigned to it
Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:22 PM
ah, sorry, i forgot to include .Value here but it's actually present in the script.


Report Abuse
OttawaSenators is not online. OttawaSenators
Joined: 09 May 2010
Total Posts: 709
03 Nov 2017 07:23 PM
Having the path coded like that isn't ideal in case you want to change your layout later (you'd have to go through and change the code, which is never very good if you can avoid it).

Instead, you can use an ObjectValue. Since it stores an object, you can just set the value itself to the weapon you want to clone and use that.

It'd look something like this:
-- Initializing the value
ObjectValue.Value = Your weapon

-- Then, later, to clone
ObjectValue:Clone().Parent = player.Backpack


-- Notice how there's no game.ServerStorage:FindFirstChild():FindFirstChild();
-- Since you're copying it in originally, none of that is needed.
Report Abuse
TaaRt is online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
03 Nov 2017 07:25 PM
Have you tried printing the results of both seperately? Also if you mean upon joining you may need WaitForChild
Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:27 PM
it's stored so there are different paths to different weapons, but in a way so that you need to specify two paths to get to it.

weapons - a folder

commercial airliner - another folder
plane - weapon

jumbo jet
jet

big bomb
nuke



Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:28 PM
these values are being stored inside the player, inside a folder called data where i save int values and string values. they aren't applying properly, i'll try posting the code here to see if i can get some help :(


Report Abuse
McRocketNuggets is not online. McRocketNuggets
Joined: 23 Nov 2016
Total Posts: 472
03 Nov 2017 07:28 PM
Seperate the two.

local clone = game.ServerStorage:FindFirstChild(house):FindFirstChild(person):Clone()
clone.Parent = player.Backpack
Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:29 PM
separating them won't change anything


Report Abuse
TaaRt is online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
03 Nov 2017 07:33 PM
local house = game.ServerStorage:FindFirstChild(house.Value)
print(house)
if house then
local weapon = house:FindFirstChild(person.Value)
print(weapon)
end

you'll want to slowly determine where the outcome isn't what you expect to pinpoint the problem
Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:33 PM
heres a ##### ### if you really wanna help /VHakeWFx
Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:34 PM
payste bin*


Report Abuse
JiggIypuffs is online. JiggIypuffs
Joined: 04 Feb 2011
Total Posts: 4346
03 Nov 2017 07:55 PM
1


Report Abuse
McRocketNuggets is not online. McRocketNuggets
Joined: 23 Nov 2016
Total Posts: 472
03 Nov 2017 08:01 PM
Jigglypuffs, first of all, your method can be easily exploited. You see, by placing a string value inside of the player, any exploiter or hacker (don't know the difference) could change that value since it's on the client's side. Also, these values are quite an inefficient way to go throughout this. I recommend learning about global variables as it would just be easier to change those values instead of changing the string values INSIDE OF THE PLAYER.
game.ServerStorage:FindFirstChild(_G.House):FindFirstChild(_G.Person):Clone().Parent = player.Backpack


One question, what are you planning to do with this code? Are you trying to save these values so when the player rejoins he is greeted with his weapons he bought, because if you are, instead of saving stringvalue's you might as well save a table using JSON.
Report Abuse
TaaRt is online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
03 Nov 2017 08:07 PM
Nothing above seems sensible to me apart from not putting the check on the client Just use remote functions if you must. _G is about as unsafe as it gets, and JSON isn't actually used in ROBLOX unless you need cross compatibility.
Report Abuse
McRocketNuggets is not online. McRocketNuggets
Joined: 23 Nov 2016
Total Posts: 472
03 Nov 2017 08:40 PM
"_G. is about as unsafe as it gets"
_G. uses the server library, and the client and server library are completely different; therefore hackers wouldn't ever be able to access the server library and won't be able to edit anything there.
"JSON isn't actually used in ROBLOX unless you need cross compatibility"
http://wiki.roblox.com/index.php?title=JSON
Report Abuse
TaaRt is online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
03 Nov 2017 08:56 PM
You do understand what I mean by cross compatibility? It is possible to use but has much simpler alternatives in ROBLOX

"You may want to consider using BindableFunctions and BindableEvents instead of global functions. If you need to communicate from client to server or server to client, then you should use RemoteFunctions and RemoteEvents."
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
03 Nov 2017 09:01 PM
How are Bindables any more safe than functions in the _G table?


Report Abuse
TaaRt is online. TaaRt
Joined: 26 Apr 2009
Total Posts: 5039
03 Nov 2017 09:14 PM
That's a wiki quote from the Global functions page, nonetheless the functionality required here is between server and client, so I don't see how _G is a viable solution to begin with.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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