|
| 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 |
|
|
| |
|
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 |
|
|
|
| 03 Nov 2017 07:22 PM |
ah, sorry, i forgot to include .Value here but it's actually present in the script.
|
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 03 Nov 2017 07:28 PM |
Seperate the two.
local clone = game.ServerStorage:FindFirstChild(house):FindFirstChild(person):Clone() clone.Parent = player.Backpack |
|
|
| Report Abuse |
|
|
|
| 03 Nov 2017 07:29 PM |
separating them won't change anything
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 03 Nov 2017 07:33 PM |
| heres a ##### ### if you really wanna help /VHakeWFx |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 03 Nov 2017 09:01 PM |
How are Bindables any more safe than functions in the _G table?
|
|
|
| Report Abuse |
|
|
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 |
|
|