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

How do I get the position of a mouseclick?

Asked by
KordGamer 155
9 years ago

I have a tool that, when clicked, spawns a horse where the person clicked. For some reason, The horse does spawn, But not at the place where someone clicks. It spawns at one location only... Could I have same help with this?

Also, Sorry for not posting any Lua code, The code is on another computer ;-;

Any help is appreciated, Thanks!

0
You could use mouse.Hit.p, but then if the player clicks in the air the horse will spawn in the air, so I hope someone has a better solution. Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

You would use Mouse.Hit to get the position of the mouse, in the game. For example:

game.Workspace.Part.Position = game.Players.LocalPlayer:GetMouse().Hit.p -- Remove the p if it doesn't work
0
Thanks :D KordGamer 155 — 9y
Ad

Answer this question