Ad
Log in to vote
0

I want to do this TP script Like you TP where your mouse is But my script wont work?

Asked by 2 months ago

ive never Done anything with Mouse, So Plz Have mercy on me Most of it is probably wrong im realy new to scripting so plz help me out

player = game.Players.LocalPlayer
mouse = player:GetMouse()
char = player.Character
tor = char.LowerTorso

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.F then
local tp = mouse:Move()
 tor.Postion = tp.CFrame
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

I want to make to make something Like the flash Step On bleach But it Wont Work At all, I just Want to be able to TP where the Mouse is

1
To get the mouse's position it's mouse.Hit.p, and to move the character use char:MoveTo(mouse.Hit.p) Jesse1240 57 — 2mo
0
Ok thx FilthyMonsterPlays 3 — 2mo
0
but doescent that only activate if i click the mouse? FilthyMonsterPlays 3 — 2mo
0
Nope. I used to think that too. Jesse1240 57 — 2mo
View all comments (3 more)
0
oh ok thx FilthyMonsterPlays 3 — 2mo
0
but i have no idea Where to put that at or how to start it sorry to Bother But can You tell me how it wold be like I started scripting About 5 days ago im pretty new So plz Tell me FilthyMonsterPlays 3 — 2mo
0
Maybe learn more of the basics. hiimgoodpack 1381 — 2mo

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

1 answer

Log in to vote
0
Answered by
Azarth 1922
2 months ago
Edited 2 months ago
-- Make your variables local, unless they have to be global. 
local inputservice = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
-- Wait for character if not available
local char = player.Character or player.CharacterAdded:wait()
local activated = false

inputservice.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then 
        activated = not activated
    end
end)

-- Anonymous function
mouse.Move:connect(function()
    -- mouse.Hit = CFrame
    -- mouse.Hit.p = Vector
    -- mouse.Hit.x = x-location

    -- Make it's activated 
    -- Make sure you're actually hovering over something and not the skybox
    if activated and mouse.Target then 
        char:MoveTo(mouse.Hit.p)
    end
end)
0
ok FilthyMonsterPlays 3 — 2mo
0
fot the most Part it works but When i activate it it wont stop moving me I putted a debounce But it still wont work But im better of then i was 4 hours ago xD thx FilthyMonsterPlays 3 — 2mo
0
Edited. Azarth 1922 — 2mo
0
what do u mean Edited I dont Understand Sorry? FilthyMonsterPlays 3 — 2mo
0
I edited it so that you can toggle when its on with the F key Azarth 1922 — 2mo
Ad

Answer this question



Ad