#the camera doesn t switch to the part as intended to when i press a key

79 messages · Page 1 of 1 (latest)

mossy tiger
#

get rid of the player added and character added events, that made it so that the code will only run when the player first joins the server

#

you would also need to change the way that the part moves because it does it relative to the world and not the player

#

i think its like part.Position = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * Vector3.new(3,1,0)

#

i think that will put the part infront of the player

#

it does?

#

whats the error

misty zephyr
#

studio** You are now Level 3! **studio

mossy tiger
#
coolDown = false
userInputService.InputBegan:Connect(function(Input, IsTyping)--ability
    if IsTyping then return end
    local keyPressed = Input.KeyCode
    if keyPressed == Enum.KeyCode[key] and not coolDown and script.Parent.Text == "V" then
        coolDown = true


        local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
        local part = Instance.new("Part")
        part.Parent = workspace
        part.Position = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * Vector3.new(3,1,0)
        part.Anchored = true
        
        cc.CameraType = Enum.CameraType.Scriptable
        local Connection 
        Connection = RunService.RenderStepped:Connect(function()        
            cc.CFrame = part.CFrame -- cc for current camera
            part.Cframe = cc
        end)
        wait(4)
        Connection:Disconnect()
        part:Destroy()
        cc.CameraType = Enum.CameraType.Custom
        
        script.Parent.Parent.ImageLabelfunni.ImageColor3 = Color3.fromRGB(0,0,0)
        local time = 8
        while wait(1) do
            if time == 0 then
                script.Parent.Text = 'V'
                script.Parent.Parent.ImageLabelfunni.ImageColor3 = Color3.fromRGB(255,255,255)
                break
            else
                script.Parent.Text = tostring(time)
                time = time - 1
            end
        end
        coolDown = false
    end
end)
misty zephyr
#

studio** You are now Level 15! **studio

mossy tiger
#

try this

#

ive tried my best i dont really understand what all the variables are but ive given it a shot lol

#

thats good better than copying code

#

all part of learning 😎

#

i think it should work the code i sent

#

i think it should but this also works but its definitely worse lol

#

whats broken now?

#

ah

#

see if this works

        Connection = RunService.RenderStepped:Connect(function()    
            part.CFrame = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * Vector3.new(3,1,0)
            cc.CFrame = part.CFrame -- cc for current camera
        end)
#

i thought it automatically changed because when its set to custom

#
coolDown = false
userInputService.InputBegan:Connect(function(Input, IsTyping)--ability
    if IsTyping then return end
    local keyPressed = Input.KeyCode
    if keyPressed == Enum.KeyCode[key] and not coolDown and script.Parent.Text == "V" then
        coolDown = true


        local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
        local part = Instance.new("Part")
        part.Parent = workspace
        part.Position = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * Vector3.new(3,1,0)
        part.Anchored = true
        
        cc.CameraType = Enum.CameraType.Scriptable
        local Connection 
        Connection = RunService.RenderStepped:Connect(function()    
            part.CFrame = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * Vector3.new(3,1,0)
            cc.CFrame = part.CFrame -- cc for current camera
        end)
        wait(4)
        Connection:Disconnect()
        part:Destroy()
        cc.CameraType = Enum.CameraType.Custom
        

        script.Parent.Parent.ImageLabelfunni.ImageColor3 = Color3.fromRGB(0,0,0)
        local time = 8
        while wait(1) do
            if time == 0 then
                script.Parent.Text = 'V'
                script.Parent.Parent.ImageLabelfunni.ImageColor3 = Color3.fromRGB(255,255,255)
                break
            else
                script.Parent.Text = tostring(time)
                time = time - 1
            end
        end
        coolDown = false
    end
end)
#

its just a change to the runservice bit

#

is cc the local camera?

#

put cooldown as false also

#

okay cool

#

so what does it do now with those changes?

#

ah okay

#

what is it?

#

ah

#

try replace it with part.CFrame = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * CFrame.new(3,1,0)

#

i think that might work im not really sure the right way with them 😂

#

hang on ill try it

#

yeah it will say it for every time renderstepped fires

#

oh nice 😂

#

pro

#

yeah thats because the cframe thing was to position it relative to the player

#

ohh i did it

#

part.CFrame = humanoidRootPart.CFrame + humanoidRootPart.CFrame.LookVector + Vector3.new(3,1,0)

#

this

#

is it ment to face the player?

#

replace it with that buy im trying to get it to spin it 180

#

so it looks at the player

#

didnt you want the part to move with the body?

misty zephyr
#

studio** You are now Level 4! **studio

mossy tiger
#

oh

#

get rid of the render stepped then i thought that was what you wanted 😂

#

okay

#

ohhh

#

runservice is if you want to change something every frame

#

you said u want the camera to stay in the same place?

#

or make it follow the player?

#

so that doesnt need to be changed every frame

neat cave
#

ok

mossy tiger
#

hi level one scripter help

#

no service

#

im currently dying

#

part.CFrame = (humanoidRootPart.CFrame + humanoidRootPart.CFrame.LookVector*CFrame.new(0,0,-3).Position) * CFrame.Angles(0,math.rad(180),0) this sets the rotation right but this is probably such a poor way to do it

#

idk what im doing with cframes 😂

neat cave
#

local script

local Camera = workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = workspace["Object Path"].CFrame
#

ok

mossy tiger
#

it should move it right at least

#

aw

#

in what way?

#

might retire from scripting

#

crying

#

did it move the camera?

#

or just freeze

neat cave
#

I dont know what you exactly want to do

#

yes

mossy tiger
#

ive almost got it working fully now

#

ayy i did it

#
--part:Destroy()
userInputService = game:GetService("UserInputService")
coolDown = true
key = "V"
cc = game.Workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character
print ("running")
userInputService.InputBegan:Connect(function(Input, IsTyping)--ability
    print ("press")
    if IsTyping then return end
    local keyPressed = Input.KeyCode
    if keyPressed == Enum.KeyCode[key] and coolDown and script.Parent.Text == "V" then
        print ("v")
        coolDown = false
        local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
        cc.CameraType = Enum.CameraType.Scriptable
        cc.CFrame = (humanoidRootPart.CFrame + CFrame.new(0,1,-10).Position)
        cc.CFrame = cc.CFrame * CFrame.Angles(0,math.rad(180),0)
        
        wait(4)
        cc.CameraType = Enum.CameraType.Custom
        part:Destroy()
        script.Parent.Parent.ImageLabelfunni.ImageColor3 = Color3.fromRGB(0,0,0)
        local time = 8
        while wait(1) do
            if time == 0 then
                script.Parent.Text = 'V'
                script.Parent.Parent.ImageLabelfunni.ImageColor3 = Color3.fromRGB(255,255,255)
                break
            else
                script.Parent.Text = tostring(time)
                time = time - 1
            end
        end
        coolDown = true
    end
end)
#

maybe i should learn how cframes work more

#

i agree with them

#

you should probably anchor the player too when the camera moves if you dont want them running off

#

omg it doesnt actually work nvm 😅

#

nice 😂

#

glad u figured it out and i learned that i dont understand cframes in the slightest 😂

#

ill make a game using them some day and ill be forced to learn

misty zephyr
#

studio** You are now Level 5! **studio