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.
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.
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
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.