How would I move this model by 10 studs and follow the mouse?
I tried making the part move 10 studs by multiplying the CFrame of the model by 10,but it didn't work.
it just moved 10 studs from the mouse away from the part.
I want it to move like the Select Tool in studio.
How would I do this?
-- 6/10/2015 By:Zobomafoo --Purpose:Creates a movable model using rays and mouse events --[[Setup]]-- Player = game.Players.LocalPlayer ------------------------------- Vairables = { Part = game.ServerStorage.Part, Mouse = Player:GetMouse()} ------------------------------- ClonedPart = Vairables.Part:Clone() ClonedPart.Parent = game.Workspace ------------------------------- IgnoreTable = {Player.Character,ClonedPart} ------------------------------- Functions = { CreateRay = function() local Ray = Ray.new(Vairables.Mouse.UnitRay.Origin,Vairables.Mouse.UnitRay.Direction*900)--Create ray from mouse and reaches 900 studs max local Hit,Pos = game.workspace:FindPartOnRayWithIgnoreList(Ray,IgnoreTable) return Hit,Pos end} --~~--~~[[Everything starts here]]~~--~~--- Vairables.Mouse.Move:connect(function() local Hit,Pos = Functions.CreateRay() if Hit then -- if hit then do the following ClonedPart:SetPrimaryPartCFrame(CFrame.new(Pos + Vector3.new(0,ClonedPart.PrimaryPart.Size.y / 2,0)*10)) --adding half the part's Y Size because then the part will be above the ground rather in halfway into the ground end end) ----------------------------------------- Vairables.Mouse.Button1Down:connect(function() local NewPart = ClonedPart:Clone() NewPart.Parent = game.Workspace end)
I assume you want to move it 10 studs straight up?
Try changing line 27 to this:
ClonedPart:SetPrimaryPartCFrame(CFrame.new(Pos + Vector3.new(0,ClonedPart.PrimaryPart.Size.y / 2,0) + Vector3.new(0, 10, 0)))