✓ Accepted answer
Storing Variables
A common mistake many developers make is they store a variable rather than grab the latest updated value. Here is an example using a BoolValue.
local boolValue = Instance.new('BoolValue', workspace)
boolValue.Value = true
local x = boolValue.Value
print(x)
print(bool.Value)
boolValue.Value = false
print(x)
print(bool.Value)
Output:
true
true
true
false
Correction
This same principle applies to your problem. You are storing Mouse.Hit.p as a variable when you actually want to get the updated version. An easy fix would be just to put mousepos inside your loop.
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
while true do
local mousepos = mouse.Hit.p
print(mousepos)
wait(1)
end
1 comment
Thanks a lot! This answer really goes in depth and I think I understand more.