Hello, could someone help me tell how the mouse works and its properties that I show in the following image with some example code, please, I am reading the API from the docs and I do not understand these points Mouse (roblox.com)
code to get mouse:
1. -- From a LocalScript:
2. local Players = game:GetService("Players")
3. local player = Players.LocalPlayer
4. local mouse = Player:GetMouse()
The Mouse.Hit just returns a Cframe of where its 3d position is compared to the camera. Most guns use this for aiming
The Mouse.Icon will just change the picture of the mouses Icon
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Icon = "A decal id I'm pretty sure"
The Mouse.Origin is just the CurrentCamera’s position
The Mouse.Target returns the BasePart that it is pointing at. If the mouse is on the skybox it will return nil, you can you Mouse.TargetFilter to filter out certain parts like raycast
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Click:Connect(function()
local part = mouse.Target
if part then
print(part.Name)
end
end)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Click:Connect(function()
local part = mouse.Target
if part then
print(part.Name)
end
end)
what’s wrong i did the localscript in StarterCharacterScripts
Mouse.Hit: The mouse CFrame (position) in 3D space. You can convert it to vector by doing Mouse.Hit.Position.
Mouse.Icon: basically the icon of your mouse. It is the cursor image (roblox decal id).
Mouse.Origin: the CFrame of the camera, that’s pointed towards the mouse.
Mouse.Target: Basically the current object the mouse is pointing to.
Mouse.TargetFilter: It basically ignores one instance and it’s descendants, which means when the mouse points on it, the target will either be nil, or the object behind it.