Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I convert a UDim2 into a Vector3?

Asked by 4 years ago

I'm attempting a placement system, and I'm trying to get a vector3 position from a player's mouse position.

0
There is a property in the mouse which tells you cframe and position. read more about it here: https://developer.roblox.com/en-us/api-reference/class/Mouse munkuush 22 — 4y
0
Position is X and Y. promanfnatfreddys 20 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Use mouse.UnitRay and create a ray instead.

This is what i do in my script

01-- Some variables are outside of this
02RunService.Heartbeat:Connect(function()
03                    local mouseRay = Mouse.UnitRay
04                    RayInfo.FilterDescendantsInstances = {Tycoon, Character}
05                    RayInfo.FilterType = Enum.RaycastFilterType.Blacklist
06 
07                    local raycastResult = game.Workspace:Raycast(mouseRay.Origin, mouseRay.Direction * 1000)
08 
09                    if raycastResult then
10                        local hit = raycastResult.Instance
11                        if hit and not string.find(hit.Parent.Name, "Tycoon") then
12                            if hit:IsA("Part") and hit.Name:lower() == "baseplate" then
13                                goodToPlace = true
14                                SetModelBrickColor(Tycoon, BrickColor.new("Bright green"))
15                            else
View all 34 lines...
0
That didnt came out good MikkelCircled 42 — 4y
Ad

Answer this question