so i have tried doing this in a localscript because for now i am making it local until it actually spawns a part then i will make it fire an event later and make the server create it instead of the client
--localscript game.Players.PlayerAdded:Connect(function(plr) local Mouse = plr:GetMouse() local cloth = game.ReplicatedStorage.Cloth cloth.Position = Mouse.Target.Position if Mouse.Button1Down then cloth.Position = Mouse.Target.Postion cloth.Anchored = true end end)
I would do it like this, insert a Local Script into Starter Gui and then the following code into the script (Yours but slightly modified)
play = game.Players.LocalPlayer char = play.Character mouse = play:GetMouse() --Gets the Players Mouse cloth = game.ReplicatedStorage.Cloth:Clone() --Clones the part mouse.Button1Down:Connect(function() --Fires if Button1 Is Clicked cloth.Position = mouse.Hit.p --Part position = mouse.Position cloth.Parent = workspace cloth.Anchored = true end)
Hopefully this helped.
EDIT Improved Script
play = game.Players.LocalPlayer char = play.Character mouse = play:GetMouse() --Gets the Players Mouse cloth = game.ReplicatedStorage.Cloth:Clone() --Clones the part clothplacing = game.ReplicatedStorage.Cloth:Clone() mouse.Move:Connect(function() clothplacing.Position = mouse.Hit.p clothplacing.Anchored = true clothplacing.Parent = char --Parented here so that it's not detected by the mouse Position and therfore wont infintely climb up the Y axis wait() end) mouse.Button1Down:Connect(function() --Fires if Button1 Is Clicked cloth.Position = clothplacing.Position cloth.Parent = workspace cloth.Anchored = true end)
Best I can do, sorry.