Hi, I'm trying to create a build preview. Where a transparent version of the part appears and follows your mouse until you like where it is then when you click it places it in that position. The problem I'm having is when you click the button to start the build preview it just places the part where you clicked it doesn't follow the mouse at all.
Here is the script I'm using, this is a localscript located inside a GUI textbutton:
script.Parent.MouseButton1Down:connect(function() GUI = script.Parent.Parent.Parent.Parent Wall = game.ServerStorage.WoodWall Player = game.Players.LocalPlayer Mouse = Player:GetMouse() if Player.leaderstats.Wood.Value >= 5 then Player.leaderstats.Wood.Value = Player.leaderstats.Wood.Value -5 GUI.Visible = false WWall = Wall:Clone() WWall.Parent = game.Workspace WWall.Transparency = .5 WWall.Position = Mouse.hit.p end end)
GUI = script.Parent.Parent.Parent.Parent Wall = game.ServerStorage.WoodWall Player = game.Players.LocalPlayer Mouse = Player:GetMouse() script.Parent.MouseButton1Down:connect(function() if Player.leaderstats.Wood.Value >= 5 then Player.leaderstats.Wood.Value = Player.leaderstats.Wood.Value -5 GUI.Visible = false WWall = Wall:Clone() WWall.Parent = game.Workspace WWall.Transparency = .5 end end) Mouse.Move:connect(function() WWall.CFrame = CFrame.new(Mouse.Hit.p.x,1,Mouse.Hit.p.z) end)
Using the Mouse movie function, it'll constantly move the part on the x and z axis, to prevent the part from moving up the y axis.
EDIT: reformatted script to prevent more errors
Yeah, the problem is the script that is in the mouse click function is only activating it when the player clicks. so of course it won't follow the mouse, I recommend doing what yoshi said and do a mouse move event, otherwise it won't work.
Just to clear things up if you didn't get why it didn't work exactly