(I WROTE THAT TITLE BECAUSE OTHER TITLES DIDN'T WORK) So, this is just a script what dosen't work, dosen't even show an error. Here it is:
local boxclone = game.ReplicatedStorage.Box:Clone() local box = game.ReplicatedStorage.Box function clicked() box:Clone() boxclone.Position = game.Workspace.Model.epia.Position - Vector3.new(0, 5, 0) end script.Parent.ClickDetector.mouseClick:connect(clicked)
You're not parenting your object anywhere after it's cloned. As mentioned on the wiki, cloned objects will not be automatically parented to a location. You must parent them manually after getting a reference to the cloned object.
You're also not doing anything on line 4 by saying box:Clone()
. That's just copying the object every time the function executes, parenting it to nil
immediately.
You're also saying mouseClick
instead of MouseClick
. Lua is case-sensitive, and sees both of those indices as different representations.
Simply just create a variable for your cloned object, and parent it:
local box = game.ReplicatedStorage.Box script.Parent.ClickDetector.MouseClick:connect(function() local boxClone = box:Clone() -- Create a variable for the cloned object -- Your code boxClone.Parent = workspace -- Parent it afterwards end)
Let me know if you have any questions.