i am a newbie at scripting but i know how to script.I am making a Tycoon Building game I have a problem where i want to make the model follow my mouse cursor once i clicked the GUI button, and i want it continuously follow the cursor once i click it
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local function round (n)
return math.floor(n + 0.5)
end
if game.StarterGui.ScreenGui.BuildModeFrame.BuildSelections.IronWall
then
game:GetService("UserInputService").InputChanged:Connect(function(input, gameProcessed)
game.Workspace.walls.ironwall:SetPrimaryPartCFrame(CFrame.new(round(mouse.Hit.Position.X),round(mouse.Hit.Position.Y),round(mouse.Hit.Position.Z)) + Vector3.new(0,5,0))
end)
end
some parts of this code isn't necessarily needed to be there. Please help and also if you can make this script more shorter that would help a lot , thank you in advance

2 comments
This is helpful but I still don't understand how to make it work though
What I'm trying to say is like a menu system with some selection of items , where if you choose it would generate a 3D blueprint