My general idea is that i want a character to have a short burst movement ability to teleport a short distance to wherever the mouse is pointed.
Now you may be asking, 'where is your code?'. Thats my problem, i dont even know where to begin to make an ability possible. All i know is that it will use the :Getmouse(), a mouse1down event. Potentially would raycasting also be needed? I dont know, i just need somebody to point me in the right direction or write out a short description of what i need to do to make it possible.
You don't need to use Raycasting for this in any way. You can use the hit mouse property to get the worldspace position of the mouse. If you only want it to work with a short distance, you can check the magnitude from that position to the Player's RootPart. If it's a short enough distance - all you have to do is teleport the player to that worldspace location with your preferred method.
(if the player becomes stuck in the floor or anything of the sort - add to the y value of the hit location).
helpful links:
Hi 27starghost, I will show you a bunch of codes and describe each of them to you. So, you want to start with Teleportation Process.
!!!!!!!!!!!!!!!!!I know that this isn't what you've asked for but it still might help you.!!!!!!!!!!!!!!!
Make sure to put 2 parts in your Workspace inside ROBLOX Studio with the size of: 4, 12.57, 5.3, and put the option CanCollide inside Properties of Both parts to false. Name them, "Teleporter1" and "Teleporter2".
Here's an image on how should that look: https://imgur.com/a/prqXC2D
First of all, you need to know how to get Character from the "Normal Script". (In this case, we are going to use hit.Parent)
Here's an example:
script.Parent.Touched:Connect(function(hit) local Character = hit.Parent -- code here end)
Well, that was a code on how to get a character from "Normal Script". Now we need to learn how to actually Teleport player from Part A to Part B! (In this case, we are gonna be using SetPrimaryPartCFrame)
SetPrimaryPartCFrame will teleport the Model's Primary Part, in this case the Player Model already has PrimaryPart which is HumanoidRootPart.
Here's an example:
local ExitPart = game.Workspace:WaitForChild("Teleporter2") -- This is a part where our Player Model needs to be teleported to -- So lets import our first code here script.Parent.Touched:Connect(function(hit) local Character = hit.Parent Character:SetPrimarPartyCFrame(CFrame.new(ExitPart.Position)) end)
So, now when we learned how to Teleport player from place A to place B, we need to finish the script!
The script for Teleporter1 will be: (Put this in a normal script inside a Part called "Teleporter1" which you've created earlier.)
local ExitPart = game.Workspace:WaitForChild("Teleporter2") -- Name of Exit Part where will Player be teleported to. local debounce = 1 -- Prevents a ton of hits at once script.Parent.Touched:Connect(function(hit) -- Executes code when Player touches the object local Character = hit.Parent if Character:FindFirstChild("Humanoid") ~= nil and debounce == 1 then debounce = 0 Character:SetPrimarPartyCFrame(CFrame.new(ExitPart.Position)) end debounce = 1 end)
And the script for Teleporter2 will be: (Put this in a normal script inside a Part called "Teleporter2" which you've created earlier.)
local ExitPart = game.Workspace:WaitForChild("Teleporter1") -- Name of Exit Part where will Player be teleported to. local debounce = 1 -- Prevents a ton of hits at once script.Parent.Touched:Connect(function(hit) -- Executes code when Player touches the object local Character = hit.Parent if Character:FindFirstChild("Humanoid") ~= nil and debounce == 1 then debounce = 0 Character:SetPrimarPartyCFrame(CFrame.new(ExitPart.Position)) end debounce = 1 end)
So, this was something basic on how to make teleport script from Part A to Part B, I hope that this will help you even a bit.
I wish you a luck in your scripting career.
Have a good day mate.