#Can anyone correct my scripting mistake here?

186 messages · Page 1 of 1 (latest)

still wren
#

it says

#

Script 'Workspace.TriggerPart.Script', Line 6

#

Camera is not a valid member of Player "Players.d0mszO"

#

feel free to call me a idiot

ashen elk
#

if u want to maniulplate the players camrea

#

then use a local script

#

local CurrentCamera = workspace.CurrentCamera

#

thats how u refrence the players camera

still wren
#

hm okay

still wren
#

local CurrentCamera = workspace.CurrentCamera

part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local camera = player.Camera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(part.Position, part.Position + Vector3.new(0, 5, 35))
end
end)

#

i have zero knowledge of lua

ashen elk
#

oh yeah

#

do wait for child

still wren
#

where?

#

im really dumb

hollow fossilBOT
#

studio** You are now Level 10! **studio

still wren
#

and i just wanted to make a game

still wren
stable plover
still wren
ashen elk
#

hold up

#

UR A FUCKING IDIOT

still wren
#

W

stable plover
ashen elk
stable plover
ashen elk
#

ohhh

#

sowwy

still wren
#

local CurrentCamera = workspace.CurrentCamera

part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local camera = player.Camera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(part.Position, part.Position + Vector3.new(0, 5, 35))
end
end)

#

but what the fuck do i add here

stable plover
ashen elk
#

local TriggerPart = workspace:WaitForChild("TriggerPart")

#

thats how

stable plover
#

Try that and u don’t need local script for it

ashen elk
#

o

#

bruh

stable plover
#

But u don’t need it (I think)

stable plover
still wren
#

Workspace.TriggerPart.Script:4: attempt to index nil with 'Touched'

stable plover
#

Do u have local part = script.Parent?

ashen elk
still wren
#

just wanted a trigger part that changes the cameras angle into 2d

stable plover
still wren
stable plover
#

First line add it

#

Or first empty line

#

Legit same thing

stable plover
still wren
#

local part = script.Parent
local CurrentCamera = workspace.CurrentCamera
local TriggerPart = workspace:WaitForChild("TriggerPart")

part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local camera = player.Camera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(part.Position, part.Position + Vector3.new(0, 5, 35))
end
end)

stable plover
#

Try it

#

Wait

#

Nvm

#

Try it

still wren
#

Camera is not a valid member of Player "Players.d0mszO"

#

'Workspace.TriggerPart.Script', Line 8

#

got back from where i started

stable plover
#

Change currentcamera to camera

#

And remove the other camera variable

still wren
#

local part = script.Parent
local Camera = workspace.Camera
local TriggerPart = workspace:WaitForChild("TriggerPart")

part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local camera = player.Camera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(part.Position, part.Position + Vector3.new(0, 5, 35))
end
end)

#

like this?

stable plover
#

In the part touched function, remove the camera variable that is inside it

still wren
#

uhh

#

ok

stable plover
#

Use that

still wren
#

this time nothing worked

#

@stable plover

stable plover
#

Give me 3 mins I gotta do smth

still wren
#

okay

stable plover
#

Okay back

stable plover
#

I don’t have time for ur answer so if it’s a local script, change it into a regular script. But if it’s a regular script, really nothing can be done because this is Roblox’s issue that hasn’t been addressed.

ashen elk
#

has he gotten it

still wren
ashen elk
still wren
#

nothing

#

camera just wont work

ashen elk
#

use LOCAL

#

then

#

currentcamera

still wren
ashen elk
#
local part = script.Parent
local Camera = workspace.CurrentCamera
local TriggerPart = workspace:WaitForChild("TriggerPart")

part.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        local camera = player.Camera
        camera.CameraType = Enum.CameraType.Scriptable
        camera.CFrame = CFrame.new(part.Position, part.Position + Vector3.new(0, 5, 35))
    end
end)
#

this

#

do this

ashen elk
#

no

#

dont do thta

#

cause ur trying to find camera inside player when its not

#

its in like gui

#

or some crazy shit

#

idfk

still wren
#

Script 'Workspace.TriggerPart.Script', Line 8 - Studio - Script:8

still wren
ashen elk
#

nicest scripter

#

more changing currentcamera

#

for

still wren
#

or i can give up

#

and just adjust to myself

ashen elk
#

allergic to reading

still wren
#

idk how to script

ashen elk
#

hit up my good pal devking!

still wren
#

I have a gf, this is just my side quest

ashen elk
still wren
ashen elk
#

oh my bad

still wren
ashen elk
#

manly

still wren
#

exactly

hollow fossilBOT
#

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

still wren
#

youre going to loser town

#

eh i dont wanna disturb ur home there

#

you got an entire bloodline there

#

youre the creator of it

#

thats very meaningful to me

#

i dont even live there

#

you're an adult right?

#

adult guy harrasses minor

#

minor

#

14

neat wagon
#
  1. go to game.StarterPlayer.StarterPlayerScripts
  2. crate a localscript
  3. paste:
local TriggerPart = workspace:WaitForChild("TriggerPart")
local Player = game:GetService("Players").LocalPlayer

TriggerPart.Touched:Connect(function(HitPart)
    if not (HitPart.Parent == Player.Character) then return end
    local Camera = workspace.CurrentCamera
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = CFrame.new(TriggerPart.Position, TriggerPart.Position + Vector3.new(0, 5, 35))
end)
still wren
#

oh shit

neat wagon
#

errors?

#

you made a localscript

#

?

still wren
#

yea

neat wagon
#

where did you make it

still wren
#

i added the triggerpart into workspace

neat wagon
#

localscripts only run in StarterPlayerScripts, Character and PlayerGui.

neat wagon
#

you can try changing it to this:

print(script:GetFullName())
local TriggerPart = workspace:WaitForChild("TriggerPart")
local Player = game:GetService("Players").LocalPlayer
print(TriggerPart)
TriggerPart.Touched:Connect(function(HitPart)
    print(HitPart)
    if not (HitPart.Parent == Player.Character) then return end
    print("setting camera..")
    local Camera = workspace.CurrentCamera
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = CFrame.new(TriggerPart.Position, TriggerPart.Position + Vector3.new(0, 5, 35))
end)
#

and send the console output here

#

is trigger part in workspace?

still wren
#

hm

still wren
still wren
#

okay

#

ok wtf

#

it made me invisible

still wren
neat wagon
still wren
neat wagon
still wren
#

oh

neat wagon
#

oh no wait

still wren
#

in this video, Ill show you how to make a script that will make the player only see from one angle. Its called 2D Camera

🎮 Check out the Gaming Channel: https://bit.ly/3L13q1i

🌟 SUBSCRIBE HERE! 🌟
https://www.youtube.com/c/DevySub

🔔 Be sure to hit the bell and turn on notifications! 🔔

💙 SOCIAL MEDIA 💙

👑Roblox Group👑
https://bit.ly/J...

â–¶ Play video
neat wagon
#

I mean

neat wagon
still wren
neat wagon
#
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local Character = script.Parent
local Humanoid = Character:WaitForChild("HumanoidRootPart")
local TriggerPart = workspace:WaitForChild("TriggerPart")

-- settings
local CameraOffset = Vector3.new(0, 5, 10)
local Debounce = .5
-- /settings

local RenderConnection

function Start2DCamera()
    Camera.CameraType = Enum.CameraType.Scriptable
    RenderConnection = RunService.RenderStepped:Connect(function()
        Camera.CFrame = Camera.CFrame:Lerp(CFrame.new(Humanoid.Position + CameraOffset, Humanoid.Position), 0.1)
    end)
end

function Stop2DCamera()
    RenderConnection:Disconnect()
    Camera.CameraType = Enum.CameraType.Custom
end

local Enabled = false
local DebounceTimer = os.clock()
TriggerPart.Touched:Connect(function(HitPart)
    if not (HitPart.Parent == Character) then return end
    if os.clock() - DebounceTimer < Debounce then return end
    DebounceTimer = os.clock()
    Enabled = not Enabled
    if Enabled then
        Start2DCamera()
    else
        Stop2DCamera()
    end
end)
#

put this in StarterCharacterScripts

still wren
#

okay

still wren
#

localscript?

neat wagon
#

localscript inside starterCHARACTERscripts

still wren
#

alr

#

then?

#

wait

#

i have to turn off the camera im using just to get this 2d camera?

#

sad

#

it works but the direction is centered

#

@neat wagon anyway to change the direction of the camera?

still wren
still wren
# neat wagon what you mean

--//Settings//--
local zoom = 140
local FieldOfView = 7

--//Do not edit unless you know what you're doing//--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Custom

local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
Camera.FieldOfView = FieldOfView
if Character then
if Character:FindFirstChild("Head") then
game:GetService("SoundService"):SetListener(Enum.ListenerType.ObjectCFrame, Character.Head)
Camera.CFrame =
CFrame.new(Vector3.new(Character.Head.Position.X + zoom, Character.Head.Position.Y + zoom, Character.Head.Position.Z + zoom), Character.Head.Position)
end
end
end)

#

this is the script im using

#

for the default camera

#

i realize that i should have

#

to delete it

#

to make the 2d camera work

neat wagon
still wren
neat wagon
#

stop one script - enable other

still wren