Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"Character to mouse" teleportation not working?

Asked by 4 years ago
Edited 4 years ago

I'm attempting to create a "character to mouse" teleportation system with a limit of 50 studs. However, when I run this LocalScript located in StarterCharacterScripts, it brings up no errors the output whatsoever, and nothing happens when I press F.

Here is the script:

01local uis = game:GetService("UserInputService")
02local player = game:GetService("Players").LocalPlayer
03local mouse = player:GetMouse()
04 
05local character = player.CharacterAdded:wait()
06local torso = character:WaitForChild("Torso")
07 
08local teleportRange = 50
09 
10uis.InputBegan:Connect(function(inputObject, gameProcessed)
11 
12        if inputObject.KeyCode == Enum.KeyCode.F and not gameProcessed then
13 
14            local position = mouse.Hit.p
15            local distance = position - torso.Position
View all 25 lines...

Any help or inquiries would be appreciated!

1
im looking into it Clorize 31 — 4y
0
Why did you put that "not" in the if statement [not gameProcessedEvent] Clorize 31 — 4y
0
so that it doesn't detect input if the player is chatting DemonHunterz6 35 — 4y

1 answer

Log in to vote
0
Answered by
ImTrev 344 Moderation Voter
4 years ago

Maybe try on line 20: torso.CFrame = CFrame.new(mouse.Hit.p). It won't keep the players rotation but that can be easily fixed. If you need anymore help or this answer didn't work just say so! I will help to the best of my abilities.

Ad

Answer this question