Mouse 3d positioning bug with roblox studio like editor ‏‏‎ ‎

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m suffering from a bug while developing my obby creator-like game, I would like a way to fix it and scripting examples would be helpful!

  1. What is the issue? Include screenshots / videos if possible!

Whenever i move my mouse to position far away from the part, it sizes up.

As you can see that is not want I want as I am trying to creating a sizing system similar to that of roblox studio. The red orb thingy should be aligned with the mouse instead of going somewhere else

  1. What solutions have you tried so far?

This type of thing is not popular enough for solutions on devhub, i have spent hours looking.

Ill give 1 robuck to whoever figures out the issue! This should not be a difficult fix!

  1. Extra Details

Here are 2 parts of my code that are related to the issue.

Functions

function roundToStep(initialValue:number,step:number)
	if typeof(initialValue) == "Vector3" then
		local dividedvalue = initialValue/step
		local roundedvalue = dividedvalue:Floor()*step
		return roundedvalue
	else
		local roundedValue = math.floor(initialValue/step)*step
		return roundedValue
	end
end

function findaxis(l,s, f) -- oh this looks confusing, this just turns all values in the vector3/cframe not on the target axis (l) to f, and the value on the target axis to s.
	local function fi(f,strin)
		if typeof(f) == "CFrame" or typeof(f) == "Vector3" then
			return f[strin]
		else
			return f
		end
	end
	local thing = Vector3.new((l == "X" and s) or fi(f,"X"), (l == "Y" and s) or fi(f,"Y"), (l == "Z" and s) or fi(f,"Z"))
	return thing
end

--[[ The issue may be with this find3dmousepos function!!! ]]---
local function find3dmousepos(Part, MaxRange) -- "Part" is what you filter
	local MousePos = US:GetMouseLocation()
	local Origin = workspace.CurrentCamera:ViewportPointToRay(MousePos.X, MousePos.Y)
	
	local IgnoreParams = RaycastParams.new()
	IgnoreParams.FilterDescendantsInstances = {Part}
	IgnoreParams.FilterType = Enum.RaycastFilterType.Exclude
	
	local Result = workspace:Raycast(Origin.Origin,Origin.Direction * 100000, IgnoreParams)
	return Result and CFrame.new(Result.Position) or CFrame.new(Origin.Origin+Origin.Direction)
end

Mini Function in Main Function

v.MouseButton1Down:Connect(function()
	if CurrentlySizingPart == false then
		CurrentlySizingPart = true
		local startMousePos = v.CFrame.Position
		local startPos = Part.Position
		local startSize = Part.Size
		MouseMovingConnection = Mouse.Move:Connect(function()
			local delta = roundToStep((find3dmousepos(Part,1000).Position - startMousePos)[Letter],1)
			local axisVector = findaxis(Letter, 1, 0)
			local sign = math.sign(delta)
			local magnitude = roundToStep(delta,1)
			local offset = axisVector * magnitude
			local newSize = oldSize + offset
			local newPosition = originalPosition + (axisVector * (magnitude*-Number / 2))
			Part.Size = newSize
			Part.Position = newPosition
		end)
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category. Ok i get it you bot

3 Likes

Yeah it is supposed to do that even in normal roblox scaling

3 Likes

Right now I’m sizing by the red orb, when I move the mouse up the part increases in size but it should only increase in size when moving it left or right for the goal I’m trying to accomplish

3 Likes

That’s pretty hard to do as far as I can tell I have not found a single game that can or does do that

2 Likes

There are actually 2 games i know one being the creative game named “Obby Creator” it sizing system is close to or parallel to that of roblox studio

2 Likes

no obby creator is I game I play almost every day it has the same size system that you have right there it will scale no matter what direction your mouse moves in

2 Likes


Can you see the difference now???!!! Dude.
For some reason the second video got weird but i am moving it up and it stays aligned with the mouse

1 Like

I fixed it but no thanks to you people :/// Its not exactly like obby creator but with a few improvements it will most likely mirror obby creator. Reply to me for the code

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.