I am trying to make a script for a script builder game.
(If you don't know what that is, you just upload a script to the game and it runs it and you can fight people etc with your scripts.)
I am just confused about how people get the players mouse in the game from a server script? I've seen people do it with guns and such.
Anyone know how to or any ideas?
You can't Server scripts are made for server side stuff only. A way you can use to obtain the player's mouse position for example is using Remote Events!
EXAMPLE: Local script:
1 | mouse = game:GetService( "Players" ).LocalPlayer:GetMouse() |
2 | remote = workspace.Remote -- remote location |
3 | wait( 10 ) -- wait 10 secs :) |
4 | remote:FireServer(mouse.Hit.p) |
Server script:
1 | workspace.Remote.OnServerEvent:Connect( function (player,HitPos) |
2 | print (HitPos) -- print mouse position in 3d space |
3 | print (player.Name) -- print player who fired it :D |
4 | end ) |
Remember that the local script should be in Clientside environment such as PlayerGui or PlayerScripts for example
Good luck!
This is correct you cannot get a mouse using a server script just like when you can't get the current camera in a server script they're only things that can be access in a local script.