Hello fellow devs!
I wanted to make a Teleport Ability for my game. I wanted the ability to have the following characteristics:
-Tool activated before teleport
-[Enum.KeyCode] or Click on mobile to teleport with cooldown
-Max Range is like 1k studs
-Cool effect before teleporting
(btw not asking for vfx, just an idea script I can def. implement and build on into my game. It would be helpful though )
I did look at some tutorials and got some background information. I think that maybe raycasting and some other useful tools can be used here
I’m not the best at scipting with characters or mouse, but can u show me an example of just a sniplet?
I really am concerned about the fact that players can just teleport so far away in an open area.
Thanks
You can do the following for your concerns on distance teleportation:
Square boundary
Calculate value of X Y Z separately of target position minus the value of X Y Z separately of player’s position and perform math.abs on each result. If one of them is over the studs, the script may return preventing the teleportation from being performed.
Radius
(vector3_1 - vector3_2).Magnitude
The formula above provides the distance between two Vector3 positions in a single stud variable. If the distance is over the amount of studs expected, the script may return preventing the teleportation from being performed.
So,
I took my time reading about mouse and its methods. I did especially look at Mouse.Hit() and it gives a CFrame back. Now there are like these other methods of Mouse like Mouse.Origin Mouse.UnitRay
What are the differences and how can I use Mouse.Hit to verify that the hit is a object or terrain and not just air?
I also want to know how I can like make a character tween into transparency and then teleport and instantly come back. Should I just tween the rootpart or the entire character in a for loop?
Thanks for the help!
To verify the mouse is on a part, you can check if Mouse.Target returns a part.
To make your character transparent, use TweenService in a ‘for i,v in Character:GetChildren() do’ loop, verify the child is a part with :IsA(“BasePart”). Luckily TweenService has an option to reverse the tween after it finishes (Check TweenInfo documentation), so you could wait the tween time, CFrame the character and it should come back automatically.