When I access it from an OLD script, it errors but still works.
It exists in the Workspace clearly because it half works with the Selection script, so what’s wrong?
Script
Build Mode Open
Player:GetAttributeChangedSignal("BuildMode"):Connect(function()
Camera.CameraType = Enum.CameraType.Scriptable
local e = game:GetService("TweenService"):Create(Camera, TweenInfo.new(0.75,Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {
CFrame = plot.CamPart.CFrame
}):Play()
local succ, err = pcall(function()
e:Play()
end)
if succ then require(game.ReplicatedStorage.Building).Init(player) else warn("Build mode could not start. Error is below.") warn(err) end
end)
local function TweenToPart()
game.Players.LocalPlayer:SetAttribute("PlayCutscene", false)
game.Workspace.Camera.CameraType = "Scriptable"
game:GetService("TweenService"):Create(Camera, TweenInfo.new(0.75, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {
CFrame = PlotsToTweenTo[PlotAt]:WaitForChild("CamPart",1).CFrame
}):Play()
end
player:WaitForChild("PlayerGui"):WaitForChild("Plot"):WaitForChild("SelectPlot"):WaitForChild("Left").MouseButton1Click:Connect(function()
if PlotAt == 1 then PlotAt = #PlotsToTweenTo else PlotAt -= 1 end
TweenToPart()
player:WaitForChild("PlayerGui"):WaitForChild("Plot"):WaitForChild("SelectPlot"):WaitForChild("chooseplot").Text = "Spawning "..script.Parent.Parent.Name.." (Plot #"..PlotAt..")"
end)
player:WaitForChild("PlayerGui"):WaitForChild("Plot"):WaitForChild("SelectPlot"):WaitForChild("Right").MouseButton1Click:Connect(function()
if PlotAt >= #PlotsToTweenTo then PlotAt = 1 else PlotAt += 1 end
TweenToPart()
player:WaitForChild("PlayerGui"):WaitForChild("Plot"):WaitForChild("SelectPlot"):WaitForChild("chooseplot").Text = "Spawning "..script.Parent.Parent.Name.." (Plot #"..PlotAt..")"
end)
Thanks!
The WaitForChild in the first code block won’t change anything.
Your error means “plot” is nil or in other words is never declared/given an initial value. You need to check the entire script and make sure “plot” is being assigned some value somewhere before this line of code executes otherwise this error will occur.
“Attempt to index nil with CamPart” means “plot” is nil. Does workspace have an instance named “Plots” inside of it?
local plot = game.Workspace:WaitForChild("Plots"):WaitForChild(game.Players.LocalPlayer.Name.."'s Plot")
If you get an infinite yield warning from this then the player’s plot doesn’t exist (or at least it’s incorrectly referenced and has a different name).
local plot
for _, aPlot in pairs(workspace:WaitForChild("Plots"):GetChildren()) do
if aPlot:IsA("Folder") then
aPlot:GetPropertyChangedSignal("Name"):Connect(function()
plot = aPlot
end)
end
end
Wait your error references line 80 again, which it shouldn’t do (because the code you replaced had fewer lines than the code it was replaced with) is there perhaps other scripts involved?