Hello! I am trying to create a thing where when they right click it will clone the block and place it in a certain position. But it doesnt work
Code: (Local script in StarterCharacterScripts)
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.Button2Down:Connect(function() local block = game.ReplicatedStorage:WaitForChild("Block") block:Clone() block.Position = Vector3.new(mouse.X, mouse.Y, mouse.Z) block.Parent = game.Workspace end)
Anyone know the fix for this?
You need to get the CFrame of the mouse first with mouse.Hit
block.Position = Vector3.new(mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z)
Edit:
local block = game.ReplicatedStorage:WaitForChild("Block"):Clone() -- clone it here so block has the value of the clone and not the one in replicated storage block.Position = Vector3.new(mouse.X, mouse.Y, mouse.Z) block.Parent = game.Workspace