I'm a beginner and i don't really understand some of the other script things but I tried making my own script so that I could learn but it didn't work :(
local click = script.Parent local button = script.Parent local block = game.ReplicatedStorage.test
click.MouseClick:Connect(function() block = block:Clone() --clones block block.parent = game.Workspace -- clone transfers to the workspace block.Position = Vector3.new(69.971, 38.673, -244.463) --puts it to the location end)
You should always use
:GetService even if you can define the service from the
DataModel. Why? Because
:GetService can still retrieve the service even if you were to change the name. The workspace is different, there's a global variable known as
You should change the properties of an instance first, then the last thing you should do is parent it, this can increase the performance of your game.
local click = script.Parent local block = game:GetService("ReplicatedStorage").test click.MouseClick:Connect(function(playerThatClicked) local cloneBlock = block:Clone() cloneBlock .Position = Vector3.new(69.971, 38.673, -244.463) cloneBlock .Parent = workspace end)
Removed the button variable because you had two variables that had the same value.
From my POV, the click variable is a ClickDetector. The
MouseClick event of the ClickDetector has a parameter which is the PlayerThatClicked.
So, after that, I created a variable for that the cloned Instance. Usually, when I just want to parent it to the workspace, I would do
block:Clone().Parent = workspace I would do it in one line, but for this case, you want to change the position so, you have to create a variable.
Then, the last are changing the Position and parenting it.
Also, I'm confused why you created variables that had the same value.
Alright So I Just Made A Few Fixes But Here You Go:
-- // Variables local Click = script.Parent local Block = game.ReplicatedStorage:WaitForChild('test') local Position = Vector3.new(69.971, 38.673, -244.463) local function PlaceMent() Block2 = Block:Clone() Block2.parent = game.Workspace Block.Position = Position end Click.MouseClick:Connect(PlaceMent)