I just started programming in Roblox a few days ago, and I'm trying to make a tool that allows the player to teleport to his or her mouse cursor's location. I've got a remote event set up to alert the server that the tool's been used, but I don't know how to transfer the variable that has the mouse's CFrame to the script. Right now, I just have it set up to print the players' name. Could anyone tell me where to go from here?
LocalScript
local tpTool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tpRemote = ReplicatedStorage:WaitForChild("TPRemote")
function getMouseCFrame()
local mousePosition = mouse.Hit.Position
print(mousePosition)
tpRemote:FireServer()
end
tpTool.Activated:Connect(getMouseCFrame) --Running GetMouseCFrame when tool is clicked
Script
local function teleportPlayer(player)
print(player.Name)
end
game.ReplicatedStorage.TPRemote.OnServerEvent:Connect(teleportPlayer)

1 comment
Don't forget to press Accept Answer if it helped!