You’re calling .OnServerEvent which means this (should) be running on the server. You then try to call Player:GetMouse() which only works on the client (i.e. local scripts).
To accomplish what you’re trying to in the above script, you’d need to send the relevant Mouse data from the client to the server as an argument.
Generic Example:
-- Local Script
local player = game.Players.LocalPlayer
local moues = player:GetMouse()
local remoteEvent = game.ReplicatedStorage.RemoteEvent
remoteEvent:FireServer(mouse.Hit.Position)
-- Server Script
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(player, mousePos)
print(mousePos) -- Prints a Vector3
end)
Try structuring it differently; Lets use LookVector of camera instead of mouse?
Server:
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local EquipBlock:RemoteEvent = ReplicatedStorage.EquipBlock
local function added(plr:Player):()
local blocksFolder = Instance.new("Folder")
blocksFolder.Name = "Blocks"
blocksFolder.Parent = plr
end
Players.PlayerAdded:Connect(added)
for i,v in Players:GetPlayers()
added(v)
end
local raycast = workspace.Raycast
EquipBlock.OnServerEvent:Connect(function(player:Player, LookVector:Vector3|any):()
if typeof(LookVector)~="Vector3" then return end
local ray = raycast(workspace,player.Character.Head.Position,LookVector.Unit*100)
print(ray.Origin,",", ray.Direction)
end)