Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to make a tool that spawn a part that is oriented where is the mouse ?

i want to do a Undertale Game but i don't know how to make gaster blaster. i mean, i need to make the gaster blaster oriented to where is the mouse. Thanks you to help me

Louis

1 answer

From the client, you can get the position of the mouse using mouse.Hit

mouse = player:GetMouse()
--This fetches the player's Mouse object

print(position = mouse.Hit.Position)
--This returns the coordinates that the mouse is pointing at. mouse.Hit returns a CFrame value - a combination of position and orientation, and CFrame.Position returns a simpler Vector3 value with just position

To run a script when input is received, you'd use UserInputService on the client

service = game:GetService("UserInputService")
--Fetch the service

function input(key) --Define a function
	if key.KeyCode = Enum.KeyCode.F then
		--fire a remoteevent 
	end
end
service.InputBegan:Connect(input) --Connect the InputBegan event to your function

This discussion is preserved as it was. New answers, comments, and votes are closed.