You see, TeleportAsync according to documentation reads I know you stated that your current teleport script works before, but I believe it’s not done in the intended way. Hope this helped, let me know if you have any questions.I would rather use teleportService:Teleport() instead. I also suggest studying how UserInputService works, since it's very fun to work with and is the preferred method of detecting user input over the PlayerMouse object: Īnd that's about it. If the distance is less than the TeleportRange, then allow then teleport. We can directly connect an anonymous function to this event, since we don't need to reference it again. Local TeleportRange = 50 - Max range you can teleport in Local Torso = Character:WaitForChild("Torso") Local Character = Player.CharacterAdded:wait() I'd suggest studying this solution to your question, to understand the use of magnitude a lot better: local Player = game:GetService("Players").LocalPlayer Similarly with your situation, we'd apply the same logic. If Distance > Range then - If Distance is larger than the "Range" constant, then it will print "Out of range"Įlse - But if it's not out of range, than it's obviously in range, so let's print "In range" Local Distance = (Vector1-Vector2).Magnitude - The distance Here's how we could check the distance: local Vector1 = Vector3.new(0,50,45) The code above will display the distance between these two 3D coordinates, which we can utilize in your situation to create a logic gate using an if statement. It's very important you enclose this vector operation in parenthesis, since the order of operations still applies, and we don't want to subtract Vector1 by Vector2.Magnitude. For example: local Vector1 = Vector3.new(0,50,45) Magnitude can give you the distance between two objects by subtracting their positions, and using this magnitude operation on the result. There's a special operation you can preform on each Vector3 value, which is called " magnitude" (or, " Magnitude").
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |