Making Local Parts Work

Hi, I’m making some parts appear locally for a tutorial but I can’t seem to get it to work. Here is the code, and yes they are both in Local Scripts. Also, here’s a picture of the parts for the tutorial.

Activation Script after clicking the button:

local Gui = script.Parent.Parent.Parent.Parent.Frame
local button = script.Parent.Parent.Close
local plr = game.Players.LocalPlayer
local Switch = plr:WaitForChild("TutorialSwitch"):WaitForChild("Tutorial")
local Page2 = script.Parent.Parent.Parent.Page2
local Page9 = script.Parent.Parent.Parent.Page9
local TPart1 = game.Workspace.TutorialAssets.WakeUpTutorial.WakeUpTutorialPath
local TPart2 = game.Workspace.TutorialAssets.WakeUpTutorial.WakeUpTutorialPointer

button.MouseButton1Click:Connect(function()
	Page2.Visible = true
    Page9.Visible = false
    Gui:TweenPosition(UDim2.new(0.127,0,-1.07,0),"Out","Quint",1,true) -- Position of your frame when its closed
    game.ReplicatedStorage.RemoteEvents.TutorialEvent:FireServer(plr)
    if Switch == true then
    local tpart1 = TPart1:Clone()
    local tpart2 = TPart2:Clone()
    tpart1.Parent = game.Workspace.CurrentCamera
    tpart2.Parent = game.Workspace.CurrentCamera
    tpart1.Transparency = 0
    tpart2.Transparency = 0
end
end)

Disabling Part:

local TPart1 = game.Workspace.CurrentCamera:WaitForChild("WakeUpTutorialPath")
local TPart2 = game.Workspace.CurrentCamera:WaitForChild("WakeUpTutorialPointer")

script.Parent.Touched:Connect(function()
	TPart1:Destroy()
	TPart2:Destroy()
	script.Parent.TrailDisable:Destroy() 
end)

I have no clue why it isn’t working, any help would be much appreciated. :smiley:

What is the issue? Are parts not appearing?

1 Like

Yes, the parts don’t even get put into the local camera. But I don’t know why they aren’t. Everything there should be right.

1 Like

It is not necessary to store the parts in the CurrentCamera anymore, just creating them and putting them in workspace is adequate, however this should not be the cause of the Parts not appearing.

Check that the code is passing if Switch == true then, easily done via print(), from your code it does not look like it would because Switch is an Instance. If you want to check it exists either do if (Switch) then OR if Switch ~= nil then. FindFirstChild returns either nil or the Instance, NOT true/false/nil.

Another thing to note is that it is better to use .Activated over .MouseButton1Click

2 Likes

You are doing this wrong.

You realise you are setting 2 part’s parents to the CurrentCamera right?

If you just want to view them, either use instance.new on the client or clone them, parent them to the workspace and position/tween them wherever you want.

If you trying Camera Manipulation (aka cutscenes, camera focusing) then you first have to do this:

local LP = game.Players.LocalPlayer
local char = LP.Character or LP.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = workspace.ChoosePart.CFrame

OP appears to be cloning the parts from replicated storage and parenting them to the Current Camera which in theory should work, even though it is now redundant.

The heck

Just parent it to workspace and position it. Parenting it to currentcamera would return nil would it not?

No, you can parent parts to CurrentCamera and they will appear, it is the old method of creating local parts before FE was forced on everyone.

I’d suggest trying out workspace and see if it works.

The reason the code is not working as I said in my post is because it is not passing the if statement. FindFirstChild does not return true.

This sorted it out for me, thanks! Btw I used the CurrentCamera method because I thought just using Workspace wasn’t working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.