![]() Once it arrives at the raycast function we create a ray using cam:ScreenPointToRay(x.y) this simply creates a ray originating from the camera that fires in the direction of the 2D mouse click. ![]() Input.Position gives us the 2D position of course. If it is, we log the pixel location of the cursor and send it over to the CastRay function. We then check to see if that button was LMB. Here is an example script, the UIS (UserInputService) InputBegan event runs whenever the player presses any button. Local pos, normal, object, material = CastRay(, ) UIS.InputBegan:Connect(function(input, gp) Return result.Position, result.Normal, result.Instance, result.Material ![]() Local result = workspace:Raycast(ray.Origin, ray.Direction*distance, params) Local char = plr.Character or plr.CharacterAdded:Wait() local UIS = game:GetService("UserInputService") When grabbing any input from the player we should use a LocalScript, we can’t grab a player’s input from the server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |