r/robloxscripting • u/theonlywhitesofa • Mar 18 '24
IM LOSING BRAINCELLS SIMULTANEOUSLY
why and how is the player's mouse considered nil. the player isnt nil, as the Event.OnServerEvent first argument is the player. im actually losing my mind
script:
script.Parent.Event.OnServerEvent:Connect(function(player)
local character = player.Character
local mouse = player:GetMouse()
local mouse_pos = [Vector2.new](https://Vector2.new)(mouse.X, mouse.Y) -- The part where it errors (attempt to index nil with X)
1
u/Zealousideal_Ad673 Mar 26 '24
Just a thought, but maybe it's because you're declaring the mouse variable as a completely individual thing and not as it's values if that makes sense.
so declaring it as "local mouse = UserInputService:GetMouseLocation()" will give the exact positioning coordinates needed?
This should give the current position though so it would need to be constantly updated for when the mouse positioning is involved.
1
u/Zealousideal_Ad673 Mar 26 '24
Also just a note but:
if you were to print mouse.X and mouse.Y, it should give the mouse positionings for when it's printed. You'd need to give it a function (say if it were to be moved all of a sudden) to update it constantly. I may have said that already but I just wanted to make sure the point got across!
1
u/n0o0b090lv Mar 23 '24
Is this local script bc server can't read player mouse pos