#Parent property of Camera is locked? Pls assist

325 messages · Page 1 of 1 (latest)

mortal glen
#

You can just edit vieePort.Camera.CFrame directly, you don't have to create a camera ( I think you just can't )

sudden leaf
#

This happens because you are setting the camera object to nil most likely with :Destroy and therefore you are getting that error

#

But could be different reasons

tawdry temple
#

Okay so we have some movement

#

I commented out the Destroy blocks and now I get this

#

So the only issue now is that the Cat icon does not pop up

#

Which I think is an issue because the previous viewport of the chest is not being destroyed and replaced with the randomly chosen reward from the chest

coarse meadow
#

ok im not sure how to fix that

#

not experienced with guis yet

tawdry temple
#

A level 2 scripter can't help us all hope is lost

coarse meadow
#

try asking in gui scripting

tawdry temple
coarse meadow
#

since they are gui scripters

clever ice
coarse meadow
#

2 S2's cant

#

gg

#

ff 15

#

go next

clever ice
#

you cant change the parent of a camera through code

#

its locked

clever ice
#

nvm u can

#

yh idk man

tawdry temple
tawdry temple
keen harbor
#

whats your issue

tawdry temple
#

So. the first two pics in this chat is the error I get when I don't have the destroy block commented out of the script.

#

What happens, the player walks over to the chest. Holds "E" to open the chest. the chest pops up, shakes a little then the contents is revealed. In this case it's a 100% chance of it being a cat.

tawdry temple
# tawdry temple

If I have the Destroy code block enabled I get the error. If I comment the destroy block out It goes through and I get this instead of the cat showing up.

sudden leaf
#

No you just have to remove the first for loop, you are checking if v’s class name is a camera then destroy it right after you try to set its parent.

tawdry temple
#

Which I'm pretty sure is because I'm not destroying and resetting the camera parent

keen harbor
#

brb

#

i have to activate my brain

sudden leaf
#

What do you mean it did not work? You are trying to change a parent of a null object?

tawdry temple
sudden leaf
#

And that is what the first for loop does

#

Oh you are checking if it is a camera too in the other for loop

tawdry temple
#

Here is the above script too

sudden leaf
#

You can keep the for loop just quit checking if it is a camera. Pardon if I say some wrong stuff I am on phone and it is not the best to red code on

marble raptor
keen harbor
#

camera has nothing to do with the cat part

tawdry temple
#

Chosen survivor

keen harbor
#

maybe youre just deleting the cat with your for loop

marble raptor
tawdry temple
sudden leaf
marble raptor
#

bro

sudden leaf
#

*table

marble raptor
#

there is no part

#

that spawns a cat

#

or a chosenSurvivor

#

oh wait

marble raptor
#

in the script

tawdry temple
#

Okay so we have movement again

marble raptor
#

i dont see

#

you spawn the cat

keen harbor
#

@tawdry temple send whole script

#

in text

tawdry temple
#

I get no more errors

marble raptor
#

yeah

tawdry temple
#

But the cat is fuckin tiny KEKL

marble raptor
#

lol

#

check the size

#

duh

#

or maybe

#

send

#

the whole script

tawdry temple
#
local runService = game:GetService("RunService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local tweenService = game:GetService("TweenService")

local chests = workspace:WaitForChild("MainFolder_Workspace"):WaitForChild("Chests")
local remotes = replicatedStorage:WaitForChild("Remotes")
local survivors = replicatedStorage:WaitForChild("Survivors")

local player = players.LocalPlayer
local chestSystemSS = player:WaitForChild("PlayerGui"):WaitForChild("ChestSystem")
local chestViewport = chestSystemSS:WaitForChild("ChestViewport")

local function openChest(chestName, chosenSurvivor)
    for _, v in pairs(player.PlayerGui:GetChildren()) do
        if v:IsA("ScreenGui") and v ~= chestSystemSS then
            v.Enabled = false
        end
    end
    chestSystemSS.Enabled = true
    for _, v in pairs(chestViewport:GetChildren()) do
        if  v:IsA("BasePart") or v:IsA("Model") then
            v:Destroy()
        end
    end
    chestViewport.Size = UDim2.fromScale(0, 0)
    local chestMesh = chests:FindFirstChild(chestName):Clone()
    chestMesh.Parent = chestViewport
    chestMesh.CFrame = CFrame.new(0, 0, 0)
    local camera = Instance.new("Camera")
    camera.Parent = chestViewport
    camera.CFrame = CFrame.new(0, 0, 4)
    chestViewport.CurrentCamera = camera
    tweenService:Create(chestViewport, TweenInfo.new(0.7), {Size = UDim2.new (0.35, 0,0.45, 0)}):Play()
    task.wait(0.7)
    for i = 1, 4 do
        tweenService:Create(chestViewport, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Rotation = 20}):Play()
        task.wait (0.3)
        tweenService:Create(chestViewport, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Rotation = -20}):Play()
        task.wait (0.3)
    end
    tweenService:Create(chestViewport, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Rotation = 0}):Play()
    task.wait (0.3)
    tweenService:Create(chestViewport, TweenInfo.new(0.7), {Size = UDim2.new (0, 0)}):Play()
    task.wait (0.3)
    for _, v in pairs(chestViewport:GetChildren()) do
        if  v:IsA("BasePart") or v:IsA("Model") then
            v:Destroy()
        end
    end
    local survivorModel = survivors:FindFirstChild(chosenSurvivor.survivorName):Clone()
    survivorModel:PivotTo(CFrame.new(0, 0, 0))
    survivorModel.Parent = chestViewport
    local cameraSurvivor = Instance.new("Camera")
    camera.Parent = chestViewport
    camera.CFrame = CFrame.new(0, 0, -3.3) * CFrame.Angles(0, math.rad (180), 0)
    chestViewport.CurrentCamera = cameraSurvivor
    tweenService:Create(chestViewport, TweenInfo.new(0.7), {Size = UDim2.new (0.35, 0,0.45, 0)}):Play()
    chestViewport.NameLabel.Text = chosenSurvivor.survivorName
    chestViewport.NameLabel.Visible = true
    chestViewport.RarityLabel.Text = chosenSurvivor.Rarity
    chestViewport.RarityLabel.Visible = true
    task.wait (1.5)
    tweenService:Create(chestViewport, TweenInfo.new(0.3), {Size = UDim2.new (0, 0)}):Play()
    task.wait (0.3)
    chestViewport.NameLabel.Visible = false
    chestViewport.RarityLabel.Visible = false
    for _, v in pairs(player:WaitForChild("PlayerGui"):GetChildren()) do
        if v:IsA("ScreenGui") and v ~= chestSystemSS then
            v.Enabled = false
        end
    end    
end

remotes:WaitForChild("OpenChest").OnClientEvent:Connect((openChest))
rare trenchBOT
#

studio** You are now Level 6! **studio

sudden leaf
#

Wait so whole problem was that you forgot to add the part that was the missing?

tawdry temple
marble raptor
#

where

#

is the fucking camera

#

position

#

😭

#

spagheti codde

#

fr

#

its not that much

sudden leaf
#

I saw this guy structure his code like asm

#

Let me grab it

marble raptor
#

other one

#

oh yeah

#

a guy

#

told me to do it like that way

sudden leaf
#

I could never

marble raptor
#

so good

tawdry temple
#

I'm trying my best okay

marble raptor
#

well

tawdry temple
#

I'm not a scripter

sudden leaf
#

Looks nice though

marble raptor
#

at least

#

i can read

marble raptor
#

IS THE

#

CAMERA

#

IN THE MIDDLE

#

U NEED

#

TO PUT

#

ALL LOCALS ON TOP

#

wit lov

keen harbor
marble raptor
#

its not necesary

marble raptor
#

there is no reason

#

for creating

#

a camera

keen harbor
#

for viewport

marble raptor
#

lemme actually see the code

keen harbor
#

u need a new camera for viewports

marble raptor
#

oh

#

i just saw

#

no

#

i just tought

#

he created a camera for move it

#

like

#

move the real camera

keen harbor
#

viewport =/= workspace

tawdry temple
#

So it's all syntaxd

keen harbor
tawdry temple
#

I have not changed anything since removing V:IsA ("Camera") or

#

Since I removed V:IsA ("Camera") or

#

It works but the cat is tiny

marble raptor
#

make the cat huge

#

just try that

#

prob works

#

idk

#

never tried uis

#

and shit

keen harbor
#

or cat closer to camera

marble raptor
sudden leaf
#

Well yea when you want to access something that doesn’t exist shit tends to break

marble raptor
keen harbor
#

@tawdry temple you should learn how to organize your code

#

itll greatly help you

tawdry temple
#

local cameraSurvivor = Instance.new ("Camera") creates a new camera no?

tawdry temple
sudden leaf
#

Yes but remember how @marble raptor said to keep locals at the top

marble raptor
#

yeah

#

fr

tawdry temple
#

So right after I create it, I'm setting it's parent to chestViewport

marble raptor
#

and tables after locals

#

man

#

i remember i saw a guy

sudden leaf
#

You don’t want your variables defined all over the place even if you are not using them right then

marble raptor
#

that tought locals you could put them anywhere

#

and he did

sudden leaf
tawdry temple
#

No

marble raptor
#

hi.Name = "Hi2"

local hi = workspace.Part

#

i saw a guy that did tat

keen harbor
tawdry temple
#

local cameraSurvivor = Instance.new("Camera") is not at the top because I create it. Set it's parent, show it then destroy it

sudden leaf
tawdry temple
#

Then I do it again but instead of it showing a chest it shows the cat

marble raptor
#

but its @tawdry temple

#

i cant read anything in it

#

:<

keen harbor
marble raptor
#

nothing

#

bom bom

#

chikibombom

keen harbor
#

if you have 738392 variables

sudden leaf
keen harbor
#

that are almost the same thing

marble raptor
#

better organized

keen harbor
#

in his script hes creating 2 cameras

marble raptor
#

he didnt get

#

712371 variables

#

:/

keen harbor
#

idk generally i just prefer to declare them when i use it

#

inside functions

marble raptor
#

thats why u arent s3!

keen harbor
#

🤓🤓🤓🤓

#

shut up

sudden leaf
#

There is this guy that wanted to make a admin system so put every command in a different module 💀

marble raptor
keen harbor
#

s3 and s4 are fucking nerds that get bullied in school

#

no bitches

marble raptor
#

hmm

tawdry temple
#

Okay

marble raptor
tawdry temple
#

So

keen harbor
#

i can get s3 but i refuse to be one of them

tawdry temple
#

Can we get back on track of how to fix the issue

keen harbor
#

except for rsc step dad

marble raptor
#

okay

sudden leaf
keen harbor
#

he cute

marble raptor
#

dam

#

you simper

sudden leaf
#

Kohl

keen harbor
marble raptor
#

@tawdry temple do

#

while true do
end

#

or

#

repeat until nil

tawdry temple
#

There is no camera staring at a cat

keen harbor
#

blud is not listening to me

marble raptor
#

then

#

what is the

#

cat

#

shit

#

omg

#

i cant

#

do this anymore

#

im out helpin this dud

keen harbor
sudden leaf
keen harbor
sudden leaf
#

Thats like -1 advice possibly the worst piece of coding advice I’ve heard definitely not like modules are meant to store stuff

keen harbor
#

☠️☠️☠️☠️

tawdry temple
#

Bruh where are the other pics what

#

Okay they're in there

keen harbor
#

im telling you for the 3rd time

tawdry temple
keen harbor
#

the problem is that your camera is too far from your cat

#

guy : asks for help

#

guy : does not listen

tawdry temple
#

I'm trying to

#

I'm going through it atm

mortal glen
# tawdry temple I'm trying to
cam.CFrame = cat.CFrame        -- The cat position 😺
  * CFrame.new(
    Vector3.new(0, 10, -10),   -- Up and in front of it
    cat.Position               -- Looking at cat
  )
#

here is a little help

tawdry temple
#

Would this work regardless of what comes up?

#

The chest is meant to work in the same way an egg would in Petsim

keen harbor
#

the cat emoji wasnt necessary

mortal glen
#

it was

#

and my bad about the code

#

i messed up somewhere

#

wait

#

i think i have it

keen harbor
#
cam.CFrame = cat.CFrame        -- The cat position 😺
  * CFrame.new(
    Vector3.new(0, 10, -10),   -- Up and in front of it 🆙🔼
    cat.Position               -- Looking at cat 👀👀😺
  )
mortal glen
#

yes thats so cool

tawdry temple
#

Holy shit

#

I fixed it

keen harbor
#

🤯 🤯

tawdry temple
#

The fix was a little easier than expected

#

and I'm not going to lie

#

Kinda makes me want to take a selfie using a 12gauge

keen harbor
#

yes just put the camera closer to the cat

tawdry temple
#

Not even

keen harbor
#

☠️

tawdry temple
#

local camera = Instance.new("Camera")
camera.Parent = chestViewport
camera.CFrame = CFrame.new(0, 0, 4)

#

That's the first one

#

local cameraSurvivor = Instance.new("Camera")
cameraSurvivor.Parent = chestViewport
cameraSurvivor.CFrame = CFrame.new(0, 0, -3.3) * CFrame.Angles(0, math.rad (180), 0)

#

That's the second one

mortal glen
#

yes but its better to have this adorable sleeping cat view

#
local cam = workspace.CurrentCamera
local cat = workspace:WaitForChild("Cat")

local distance = 3 -- 📏📐

cam.CameraType = Enum.CameraType.Scriptable -- 📜📜📜
cam.CFrame = CFrame.new( -- 📦📦📦📦🎯🎯
    (cat.CFrame * CFrame.new(0, distance, -distance)).Position, -- 😺😺😺😺😺
    cat.Position -- 👀👀😺😺😺😺
)
#

free to go

#

wait

#

i forgot the emojis @keen harbor

tawdry temple
#

I even put the camera check back into the destroy blocks and it works

#

Now it won't go away

keen harbor
mortal glen
#

no since it wont work you need to comment them 🤓

keen harbor
#

🤓 🤓

#

windows shortcut to get emojis is annoying

#

and also i have to search them

#

😔

mortal glen
#

:(

#

i just type win + .

#

then type emojis

#

better than linux

#

ctrl + maj + u + 1F431

tawdry temple
#

SFIGJHBNSDKFG

#

HOLY SHIT WE DID IT

#

GUYS

#

WE FUCKIN DID IT

keen harbor
#

(*/ω\*)

#

bru wtf is that

keen harbor
#

:-P

tawdry temple
#

So the big issue was I tried to set the second instant of camera as the same name from the first

mortal glen
#
print(b"\u1F431".decode("utf-8")
tawdry temple
#

Which is something a level 2 scripter should have seen 🤓

mortal glen
zealous plinthBOT
#
Program Output
ὃ1
tawdry temple
#

(I'm jokin)

mortal glen
#

fuck

keen harbor
#

unorganized

mortal glen
tawdry temple
#

Get yo glasses

mortal glen
zealous plinthBOT
#
Compiler Output
File "/app/output.s", line 1
    print(b"\u1F431".decode("utf-8")
         ^
SyntaxError: '(' was never closed
tawdry temple
#

Should have gone to specsavers

keen harbor
#

get yo scripting courses

mortal glen
#

alr time to sleep

tawdry temple
#

I mean if I wanted to clean it up I'd just go through and smash return around code blocks

coarse meadow