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

How to wake a rotating part script, similar to the way you inspect a gun in Phantom Forces?

Asked by 5 years ago

As explained in the title I am working on a game that requires that kind of part rotation (click+drag to rotate) as a main mechanic. I don't require that the script be created, that is against the rules i believe, I just want to know where to start and where to look for more info.

0
look for youtube tutorials for an idea User#19524 175 — 5y

3 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

OR!!!!

You can make the object's position/CFrame the mouse.Hit.p right?

Here's a quick example:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Object = --bla bla bla
Mouse.Changed(function())
Object.Position = Mouse.hit.p
end)

Haven't tested it out but I am pretty sure it might work.

You can also use UserInputService(UIS) for the rotation part.

another example:

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input))
if input.KeyCode == Enum.KeyCode.R then // You can change R to whatever you want
Object.Orientation = Object.Orientation + Vector3.new(0,0,0)--Change the number to your amount!
end
end)
UIS.InputEnded:Connec(function(input))
if input.KeyCode == Enum.KeyCode.R then
return
end
end)
0
That's by clicking. Not dragging. And that's position. He wants rotation. chexburger 358 — 5y
0
I was just going to make the rotation part, just let me continue mixgingengerina10 223 — 5y
0
not sure about the InputEnded part though. mixgingengerina10 223 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Try checking out this tutorial on YouTube. It should help you.

https://www.youtube.com/watch?v=NSvBg7IYe7g

0
Could've been a comment, plus the video is quite old mixgingengerina10 223 — 5y
0
Oh well. Doesn't really matter. There are new ones, old ones. chexburger 358 — 5y
0
close, but not quite what I was thinking of more like how the camera moves or how you can rotate an object in a 3d program keeping the mouse still while being able to rotate the object in all directions. qweekertom 0 — 5y
0
Look on YouTube for a tutorial. I didn't actually watch that so I had no idea it was Camera Manipulation. chexburger 358 — 5y
View all comments (2 more)
0
It actually does matter, old videos tend to not work in FilteringEnabled and have a ton of deprecated code. green271 635 — 5y
0
^ User#19524 175 — 5y
Log in to vote
0
Answered by
RAYAN1565 691 Moderation Voter
5 years ago
Edited 5 years ago

You need to first figure out when the mouse button is held down and when it is released:

local down, mouse = 0, game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
    down = true
end)

mouse.Button1Up:Connect(function()
    down = false
end)

while true do
    wait()
    if down then
        --Insert rest of code that captures position/direction of mouse and rotates the object accordingly.
    end
end

Create the rest of the code in that if the mouse is moving to the left then the object rotates to the left. If the mouse moves up then the object rotates up. The same for moving to the right and moving down.

Answer this question