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

How would i make so the camera goes to the brick you clicked?

Asked by
DevingDev 346 Moderation Voter
6 years ago
Edited 6 years ago

I have this script that i would want so if i click on a script it opens a gui that you can click on and the camera goes to that object the mouse is over when you click the gui but i want it so the camera goes to the object you clicked on not the object the camera is over when you click the gui,

heres the script

Mouse.Button1Down:connect(function()
    if Mouse.Target then
        if Mouse.Target.Parent:IsA("Model") and Mouse.Target.Name == "Hitbox" then
            local TargetPos = workspace.CurrentCamera:WorldToScreenPoint(Mouse.Target.Position)     
            UI.Frame.Visible = true
            UI.Frame.Position = UDim2.new(0,TargetPos.X,0,TargetPos.Y)
            targeting = Mouse.Target.Parent

            UI.Frame.Sample.MouseButton1Click:connect(function()
                workspace.CurrentCamera.CameraSubject = Mouse.Target
                UI.Frame.Visible = false
            end)
            --script.Parent.Frame.ItemName.Text = Mouse.Target.Parent.Name
        else
            UI.Frame.Visible = false
        end
    else
        UI.Frame.Visible = false
    end
end)
1
You would need to store the part when you click to be used at a later stage when you click the gui. User#5423 17 — 6y
0
Ya i could do that but, i would want it so i just can click on every part with a part named hitbox in it, With one script like i have already but so if i click a object and then the gui the camera goes to that part not the part the mouse if hovering over DevingDev 346 — 6y
0
You said "but," then just restated your irrelevant premise. Store mouse.Target in a variable. cabbler 1942 — 6y

Answer this question