I was wondering how to find the player's mouse using a Server Script, since you can only get it through a local script. Is there a way to pass the mouse found on the local script to the server script? I appreciate the help.
local script
local Tool = script.Parent
local player = game:GetService("Players").LocalPlayer
Tool.Activated:Connect(function()
local mouse = player:GetMouse()
local mouseTarget = mouse.Target
if (mouse.Target.Parent.Name == "GoldOre") then
game.ReplicatedStorage.PickaxeHit:FireServer(mouseTarget)
end
end)
server script
game.ReplicatedStorage.PickaxeHit.OnServerEvent:Connect(function(player)
local Tool = player.StarterGear:FindFirstChild("GoldPickaxe")
local ting = 0
local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
if ting == 0 then
local user = player
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Gold")
cash.Value = cash.Value +1
end
end
end)

3 comments
For what reason do you need the mouse? RemoteFunctions should let you pass in any data you think is relevant. https://wiki.roblox.com/index.php?title=API:Class/RemoteFunction
I realize now you're using RemoteEvents and are already trying to pass in a mouseTarget (is that what you mean by mouse?). If that's the case, just add an extra parameter to the function in server "function(player, mouseTarget)..." and mouseTarget should reference the same thing it did in the localscript.
If I replace mouseTarget with just 'mouse' (which is a variable in the local script), and add 'mouse' as a parameter in the function in the server script, i thought it would pass that variable into the server script, but it doesn't?