Can't set value of the mouse?

Hello, I’m trying to make the Y position of the mouse that goes up 0.2 every seconds. But it gave me the error Can't set value on line 7!

This is my code :

local flash = 0.2

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

while wait(1) do
    mouse.Y = mouse.Y + (flash)
end

Can anyone fix this?

1 Like

Nobody can fix it. You cannot write to the mouse position. This is for obvious security reasons.

So why some shooting game player mouse can goes up when player shooting?

I do not understand. But you can try making a custom mouse.

I think they usually do that by shifting the camera angle up.

1 Like

Do you mean recoil? If so then this is actually the players camera being adjusted, not the mouse itself.

Here is a article on camera manipulation that you might find helpful if you are trying to create this effect:

I believe what he’s referring to is recoil, which is indeed done by camera manipulation. I happened to be looking in to the same thing a little while back and came across this thread that had a solution I found interesting.

Ooh yes! Excuse my misuse of terminology. I am not a huge shooter guy.

1 Like

No shooter game ever makes the mouse move up, not on Roblox and I’m quite sure not outside either: if there are, those cases are mostly obscure.

If what you’re trying to do is recoil, what shooter games do is change where the camera is looking at by applying an offset value. Naturally, when your camera moves up, so does where you’re pointing at. For bullet spread, the position of the mouse is taken and a random offset is applied within a certain range.