I have the following code in a LocalScript, which is in a ImageButton. But it won't clone. Why?
script.Parent.MouseButton1Click:connect(function() a = game.Lighting:FindFirstChild("First") --The name of the thing is called First. a:Clone(game.Workspace) a.VehicleSeat.Vars.Owner.Value = game.Players.LocalPlayer.Name end)
There is no Output...
I've never seen :clone() used that way, with the parent as a parameter, and I can't find any documentation on the wiki that says it can work with that. But if that has worked for you before, sure.
Assuming that clone can work that way, I think I might see your problem. In line 2, you're setting a
to a thing called "First" in Lighting. Great. Then, line 3, you clone it and put the copy into Workspace. Then you set the owner value in a
. The issue that a
is a thing in Lighting, and that never changed. You changed the owner variable of the backup model in lighting, not the new one that you copied into workspace. You actually just copied it into workspace and forgot about it. You probably instead want a
to be a reference to your new thing, rather than the original backup model in Lighting. I would suggest:
script.Parent.MouseButton1Click:connect(function() a = game.Lighting:FindFirstChild("First"):clone() a.Parent = game.Workspace a.VehicleSeat.Vars.Owner.Value = game.Players.LocalPlayer.Name end)
Clone(game.Workspace) wouldn't be possible.
script.Parent.MouseButton1Click:connect(function() a = game.Lighting:FindFirstChild("First") --The name of the thing is called First. a:Clone().Parent = Workspace a.VehicleSeat.Vars.Owner.Value = game.Players.LocalPlayer.Name end)
Strange, I'm having the same problem too with my own script, I think Roblox broke this coding for GUIs aswell. :/ Silly isn't it?
Edited;
Instead of doing a:Clone()
and a.Parent
seperate, try it like this;
local a = game.Lighting:FindFirstChild("First",true):Clone() --The name of the thing is called First. script.Parent.MouseButton1Click:connect(function() local b=a:Clone() b.VehicleSeat.Vars.Owner.Value = game.Players.LocalPlayer.Name end)
Hope this helped!