Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[UPDATE] Claiming Cloning and Instance new messed up whats wrong?

Asked by 7 years ago
Edited 7 years ago

So, Im trying to make a basic game were currently you can claim a "Jeep" and It clones it into a folder and eventally any edits to your jeep are saved and copied into your own folder and the speed can be edited and ectra. My problem is the output log has just gone mental for me and I have no idea what its trying to do. I'll I know is that Ive tried Ive changed LocalPlayer to LocalPlayerT to see if thats the problem but. No.

local PlayVech = game.Players.LocalPlayer.Instance.new("Folder")
PlayVech.Name = ("CarComp")
PlayVech.Parent = game.Players.LocalPlayer
print("MadeFolder")
--- Created the folder called Carcomp which is were data of levels and info is placed.
LocalPlayerT = game.Players.LocalPlayer
LocalPlayerT.leaderstats.Level:Clone()
LocLeaderStats = LocalPlayerT.leaderstats
LocLeaderStats.Level.Parent = LocalPlayerT.CarComp
print("CopiedLocalLevelStats")
print("LoadingNextSteps..")
--- Takes level
LocalPlayerT.CarComp.Instance.new("Model")
game.Workspace.JeepNoOwner:Clone()
game.Workspace.JeepNoOwner.Parent = LocalPlayerT.CarComp.Model
LocalPlayerT.CarComp.Model.Name = ("JeepOwned")
--- Should Copy and paste a CLONE Of the jeep into a model in car comp.

No idea if it not working because Im Copying and pasting this into the player bit or its just because Im dumb and new. Tried debugging it but It came back messed up and I dont know what Ive done thanks for trying if you have.

P.s where is says LocalPlayer and CarComp There both inside the Player, wonder if thats messed it up.

PP.s When re reading this Instance.new didnt come up maybe thats it?

UPDATE:

So I've done what I think you've said and implemented it I hope this is right.

local PlayVech = Instance.new("Folder", game.Players.LocalPlayer)
JeepCloneVar = LocalPlayerT.leaderstats.Level:Clone() --- Making the var for the clones.
NewJeep = game.Workspace.JeepNoOwner:Clone()
PlayVech.Name = ("CarComp")
print("MadeFolder")
--- Created the folder called Carcomp which is were data of levels and info is placed.
LocalPlayerT = game.Players.LocalPlayer
LocalPlayerT.leaderstats.Level:Clone()
LocLeaderStats = game.Players.LocalPlayer.leaderstats
LocLeaderStats.Level.Parent = LocalPlayerT.CarComp
print("CopiedLocalLevelStats")
print("LoadingNextSteps..")
--- Takes level
LocalPlayerT.CarComp.Instance.new("Model")
game.Workspace.JeepNoOwner:Clone()
NewJeep.Parent = LocalPlayerT.CarComp.Model
LocalPlayerT.CarComp.Model.Name = ("JeepOwned")
--- Should Copy and paste a CLONE Of the jeep into a model in car comp.

So this should work now? I hope so..

0
On the second line you have LocalPlayerT if it is not created before then it will not work you need to more the LocalPlayerT = game.Players.LocalPlayer line up to the top User#19239 0 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You can't do local PlayVech = game.Players.LocalPlayer.Instance.new("Folder") instead do local PlayVech = Instance.new("Folder", game.Players.LocalPlayer)

and if you do that remove the PlayVech.Parent = game.Players.LocalPlayer as the second argument in the Instance.new sets the parent (although it is optional)

You also need to fix it for any other time you use Instance.New

Another thing is that when you are cloning store the cloned in a new local variable, so you have a reference to it, as when you clone Instances, they do not have a parent, and are not actually in the game

Creating a variable for the cloning you would do

local newvar = LocalPlayerT.leaderstats.Level:Clone() replace newvar with whatever you want to call your variable and that variable will be your reference to the new cloned instance

the same for the other one

local newjeep = game.Workspace.JeepNoOwner:Clone()

change newjeep all you like just use that as a reference for the new one

instead of doing game.Workspace.JeepNoOwner.Parent = LocalPlayerT.CarComp.Model to reference the new jeep just do newjeep.Parent = LocalPlayerT.CarComp.Model

0
Ok so How would I make the variable and refrence it? Im new so things get confusing quickly. SpinnyWinny 0 — 7y
0
Ive edited it if you need more info just comment and Ill try to explain User#19239 0 — 7y
0
So Ive ended up with something like this. SpinnyWinny 0 — 7y
Ad
Log in to vote
0
Answered by
Hexcede 52
7 years ago
Edited 7 years ago

What you're looking for is this:

local PlayVech = Instance.new("Folder", game.Players.LocalPlayer)
JeepCloneVar = LocalPlayerT:WaitForChild("leaderstats"):WaitForChild("Level"):Clone() --- Making the var for the clones.
local NewJeep = workspace:WaitForChild("JeepNoOwner"):Clone() -- Wait for it and then clone
PlayVech.Name = "CarComp"
print("MadeFolder")
--- Created the folder called Carcomp which is were data of levels and info is placed.
LocalPlayerT = game.Players.LocalPlayer
LocalPlayerT.leaderstats.Level:Clone() -- Already waited for above (will error if destroyed)
LocLeaderStats = game.Players.LocalPlayer.leaderstats
LocLeaderStats.Level.Parent = LocalPlayerT.CarComp
print("CopiedLocalLevelStats")
print("LoadingNextSteps..")
--- Takes level
local CarCompM = Instance.new("Model", LocalPlayerT.CarComp)
workspace:WaitForChild("JeepNoOwner"):Clone()
NewJeep.Parent = CarCompM
CarCompM.Name = "JeepOwned"
--- Should Copy and paste a CLONE Of the jeep into a model in car comp.

Notes: You should use workspace (game.Workspace is big and why not use the variable?) To instantly parent a new object use Instance.new(class, parent) The above returns the new instance (like clone, but clone can't parent on its own) You can also do something like this to make an instance:

local part = Instance.new("Part")
part.Position = Vector3.new(1, 3, 4)
part.Anchored = true
part.Parent = workspace

The above will create a part at the position 1, 3, 4 and anchor it... Its not instantly parented so it will only exist in the workspace after you assign those properties. Can be very useful sometimes.

0
Thanks SpinnyWinny 0 — 7y

Answer this question