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

[Solved] Why can't I print the mouse's location?

Hi! I just got started with Roblox scripting a few days ago. I'm trying to make a tool that lets you click on a location and teleport to it. I'm starting it off by trying to print the mouse's location when you use the tool, but nothing happens when I click and I'm not getting any errors. I don't know if I'm going about this in a totally wrong way or if I'm slightly off.

local tpTool = game.StarterPack.TPTool
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

function getMouseCFrame()
	local mousePosition = mouse.Hit.p
	print(mousePosition)
end

tpTool.Activated:Connect(getMouseCFrame)

2 comments

0

Please put it as the accepted answer so others know it's resolved

0

how?

1 answer

✓ Accepted answer

local tpTool = game.StarterPack.TPTool this is not the reference to the tool that you have currently equipped, my advice is to move the localscript within the tool and do script.Parent instead

1 comment

0

Thanks, that worked!

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