Down here is my localscript. If I were to run this script in local script, it would print out 'instance'
player = game.Players.LocalPlayer character = player.Character mouse = player:GetMouse() team = player.Team hit = mouse.Hit print(mouse) local ReplicatedStorage = game:GetService("ReplicatedStorage") local hitre = ReplicatedStorage:WaitForChild("hitre") hitre:FireServer(mouse.Hit, team, player:GetMouse())
Down here is the (compromised) serverscript. If I were to run this, it would print out 'nil'
ReplicatedStorage = game:GetService("ReplicatedStorage") UserInputService = game:GetService("UserInputService") hitre = Instance.new("RemoteEvent",game.ReplicatedStorage) hitre.Name = "hitre" hitre.OnServerEvent:connect(function(player, hit, team, mouse) print(mouse) end)
Why is that?
The player:GetMouse() event only works in local scripts. Doesn't matter if you try to parse it to a server script through a remote event, it won't work
well the thing is, LocalScripts run on the player's device..A mouse is "local" to a player, therefore b/c localscripts run on the player's computer, they can access the mouse.. on the other hand, the server is what connects all the players.. it doesn't control any aspects relating to the player's device.. that's why you can only detect Key down/up events only in localscripts..
Actually, the thing about mouses is that their local sided. A mouse on the players side will be different for each player and a server script handles all players. Local scripts can only handle mouses, as its a local element. Hope that helps!
That's because local scripts control things on clients for e.g. Mouse, GUI, and other things on the CLIENT
While Server scripts controls pretty much everything except not clients