I was making a weapon and one of the first things I needed to get was the mouse pos. not very hard to do, it should've taken me 1 min but instead took me 3 hours. This was the original code I was working with that didn't work - the only difference is that the 1st EX used 2 vars to get the mouse P and the 2nd EX used 1 var to get the mouse P
Local Script OG code This code would only print out a single position value even when the mouse was obviously not near that position
local RE = script.Parent.Parent:WaitForChild("mouse")
local tool = script.Parent.Parent
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local hit = mouse.Hit *the difference*
tool.Activated:Connect(function(plr)
local position = hit.Position *the difference*
RE:FireServer(position)
end)
Local script This code actually printed the correct position of the mouse no matter where it went
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local RE = script.Parent.Parent:WaitForChild("mouse")
local tool = script.Parent.Parent
tool.Activated:Connect(function(plr)
local position = mouse.Hit.Position *the difference*
RE:FireServer(position)
wait()
end)
My question is that why does code placement matter so much if, in my example "the difference" in the code really wasn't different, both sections of code should've executed the same results. if I'm wrong, why does the placement matter so much????
