✓ Accepted answer
A ServerScript cannot get a player's mouse, therefore this would not work.
What you would have to do is insert a LocalScript into StarterPlayer > StarterPlayerScripts and insert the following code:
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local function inputBegan(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and mouse.Target.Parent ~= localPlayer.Character then
if Players:GetPlayerFromCharacter(mouse.Target.Parent) or mouse.Target.Parent:FindFirstChild("Humanoid") then
local targetCharacter = mouse.Target.Parent
local huamonidRootPart = targetCharacter:WaitForChild("HumanoidRootPart")
end
end
end
UserInputService.InputBegan:Connect(inputBegan)
Note that this only works for a player's character, not NPC's.
2 comments
Thx
np