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

How do I convert a UDim2 into a Vector3?

1 answer

Use mouse.UnitRay and create a ray instead.

This is what i do in my script

-- Some variables are outside of this
RunService.Heartbeat:Connect(function()
					local mouseRay = Mouse.UnitRay
					RayInfo.FilterDescendantsInstances = {Tycoon, Character}
					RayInfo.FilterType = Enum.RaycastFilterType.Blacklist

					local raycastResult = game.Workspace:Raycast(mouseRay.Origin, mouseRay.Direction * 1000)

					if raycastResult then
						local hit = raycastResult.Instance
						if hit and not string.find(hit.Parent.Name, "Tycoon") then
							if hit:IsA("Part") and hit.Name:lower() == "baseplate" then
								goodToPlace = true
								SetModelBrickColor(Tycoon, BrickColor.new("Bright green"))
							else
								goodToPlace = false
								SetModelBrickColor(Tycoon, BrickColor.new("Really red"))
							end
							
							local Pos = raycastResult.Position
							
							local X = Pos.X
							local Y = Pos.Y
							local Z = Pos.Z
							
							X = Round(X)
							Z = Round(Z)
							
							local newCFrame = CFrame.new(X, Y + yBuildingOffset, Z)
							Tycoon:SetPrimaryPartCFrame(newCFrame)

						end
					end
				end)

1 comment

0

That didnt came out good

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