local plr=game.Players.LocalPlayer local cam=game.Workspace.CurrentCamera local mouse=plr:GetMouse() cam.CameraType="Scriptable" cam.CameraSubject=game.Workspace[plr.Name.."Cube"] while wait() do local cf=game.Workspace[plr.Name.."Cube"].CFrame.p local size=game.Workspace[plr.Name.."Cube"].Position.y/2 game.Workspace[plr.Name.."Cube"].CFrame=CFrame.new(cf.x,size,cf.z)*CFrame.Angles(0,0,0) game.Workspace[plr.Name.."Cube"].Velo.velocity=(mouse.Hit.p-game.Workspace[plr.Name.."Cube"].Position)*Vector3.new(1.5,0,1.5) cam:Interpolate(game.Workspace[plr.Name.."Cube"].CFrame+Vector3.new(0,game.Workspace[plr.Name.."Cube"].Siz.Value*0.8+20,0),game.Workspace[plr.Name.."Cube"].CFrame,0.01) local val=game.Workspace[plr.Name.."Cube"]:GetMass()*100 game.Workspace[plr.Name.."Cube"].Velo.MaxForce=Vector3.new(val,val*2,val) end
It is very glitchy how can I fix that? You can see for yourself here: http://www.roblox.com/games/315301083/Minigames
This is a suggestion of a different way to fix it:
You could use camera.CoordinateFrame
, which is basically changing where the camera is positioned, and where it is looking. It uses CFrame
.
E.G:
local cam = game.Workspace.CurrentCamera -- inserts a part to look at local part = Instance.new("Part",game.Workspace) part.Anchored = true part.BrickColor = BrickColor.new("Really black") part.Position = Vector3.new(0,10,0) -- while loop to change where the camera is facing while wait() do cam.CoordinateFrame = CFrame.new(game.Workspace.Baseplate.Position,part.Position) end
CFrame values basically go like this:
Argument #1:
Vector3
value, position of the camera, in the script above, it makes the position of the camera the same as Baseplate
's position.
Argument #2:
Vector3
value, what the camera is looking at, in the script above, it is looking at the black Part
.
For more info on CFrame
: http://wiki.roblox.com/index.php/CFrame
When trying to be above a part that is moving, you need to have the first argument of CoordinateFrame
's CFrame to be in the same position of the part that is moving, so you can always see it, and that it is in the center of the screen.
Like so:
local p = game.Workspace.TestPart p.Anchored = true local cam = game.Workspace.CurrentCamera while wait(.01) do p.Position = p.Position + Vector3.new(0.01,0,0) -- moves it on the X axis. cam.CoordinateFrame = CFrame.new(p.Position + Vector3.new(0,10,0),p.Position ) end
This script should move a Part
on the X
axis every hundredth of a second, and make the camera look at the Part
.
Also, the reason I am adding to the CoordinateFrame
's first argument is because I want to see the Part
, not look at it while inside the Part
(which is basically impossible).