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

How to have a part cframe move away from you?

Asked by
Nickoakz 231 Moderation Voter
10 years ago

I'm trying to make cartoon effects to this tiny map, where the border of the block is black. You should never see a black part in front of any part. How do you do this to the camera?

So far, this is what I managed. Yet, the parts stay and don't move away from the cam.

local plr=game.Players.LocalPlayer.Character
local cam=Workspace.CurrentCamera
game:GetService('RunService').Stepped:connect(function()
    if cam:findFirstChild("Carto")~=nil then
        cam.Carto:Destroy()
    end
    n=Instance.new("Model",cam) n.Name="Carto"
    local all=Workspace.Model:getChildren()
    for a=1,#all do
        local p=all[a]:Clone()
        p.CFrame=all[a].CFrame+Vector3.new(cam.CoordinateFrame)
        p.Parent=cam.Carto
    end
end)

2 answers

Log in to vote
-1
Answered by
KAAK82 16
10 years ago

one guy told me on the Forums once, get the Torso.CFrame.lookVector and then it will face that direction, so if it's in front of u, u can set it to Face were ur Torso is facing, orif it's behind then, were ur back is facing, and so on...

0
uhhh... am NOOB-Sick! NOOBS = Me Sick! KAAK82 16 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

You can find the direction from the players head towards the block, and then move the "outline" 0.5-1 stud away.

function getdir(head, outline)
    dir = (head.Position - outline.Position).unit
    outline.Position = part.Position + 0.5(dir)
end

I don't know a whole lot about the camera (almost nothing) but if the camera has a "position" than you can substitute the camera's position for the head's position.

Answer this question