I made a ClickDetector brick that would spawn a part on top of it whenever a player clicked on it. It isn't working, unfortunately.
script.Parent.ClickDetector.MouseClick:connect(function() x = Instance.New("Part") x.BrickColor = BrickColor.New("Institutional White") x.Position = Vector3.New(12.5, 43.4, 29.5) x.Size = Vector3.New(1,1.2,1) x.Material("Foil") x.Shape("Ball") end)
(I'm not good with scripting so it would be amazing if I could get this to work)
The reason it isn't working, is because the new instance doesn't have a parent! You created an object in nothing, and therefore there is nothing
To fix this, simply set a parent in it in one of 2 ways!
x = Instance.New("Part", parentLocation) --Set the parent the moment it is created!
or
x = Instance.New("Part") x.Parent = parentLocation --Set it after the creation; your call.
It fixed some things, but now line 5 is wrong.
x.Position = Vector3.New(89.5, 3, -10.5)
I know that the positioning is above the button itself. The button is 1x1.