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

Vector3 value not changing in real time but has no errors?

Asked by 6 years ago

Vector3 value not changing in real time but has no errors. Thanks for helping. I will appreciate even when you try

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

mouse.Move:Connect(function()
    script.Parent.MousePosition.Value = Vector3.new(mouse.Hit)
    print(script.Parent.MousePosition.Value)
end)

1 answer

Log in to vote
1
Answered by
WoolHat 53
6 years ago

mouse.Hit

returns the CFrame that the mouse is over. It's weird that passing a CFrame into Vector3.new's parameters doesn't yield an error, but I got the same result.

Solution: Use

script.Parent.MousePosition.Value = mouse.Hit.p

The ".p" takes only the positional component of your "mouse.Hit" CFrame. Because Position is a Vector3, you don't need to cast it into one, either.

0
tiny note : the new syntax for getting the position part of a cframe matrix is CFrame.Position, not CFrame.p theking48989987 2147 — 6y
Ad

Answer this question