Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to cframe to the a object to the mouse postion?

local Button = script.Parent
function onClick()
	game.ServerStorage.Couch:clone().Parent = workspace
	crframe to the mouse Button
	if you click again it will place to object
end
Button.MouseButton1Click:connect(onClick)

how to cframe to a place and with u click again it becomes a solid model that cant move anymore?

2 answers

✓ Accepted answer

Not exactly sure if this is what you're expecting but here is a custom dragger you can use

--Just your basic LocalScript Variables
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local clone
local down


function clickObj()
	local target = mouse.Target
	--You can add if targer.Name == "Couch" then
	clone = mouse.Target:Clone()
	mouse.TargetFilter = clone
	down = true
end
mouse.Button1Down:connect(clickObj)

function mouseMove()
	if down then
		local posX,posY,posZ =  mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
		clone.Position = Vector3.new(posX,posY,posZ)
	end
end
mouse.Move:connect(mouseMove)

function mouseDown()
	if down then
		down = false
		local posX,posY,posZ =  mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
		clone:remove()
		mouse.TargetFilter = nil
	end
end
mouse.Button1Up:connect(mouseDown)

1 comment

0

wow this is amazing C:

If you're just setting the CFrame to that of the button:

Couch.CFrame = Button.CFrame

or

Couch.Position = Button.Position

If you're talking about moving it with the the player's mouse, you would need to continuously set the object's CFrame to mouse.Hit until you do whatever action you want to do where then you would stop the loop.

This discussion is preserved as it was. New answers, comments, and votes are closed.