button.MouseButton1Click:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
if isFocusedOnShopcam then
if cameraSpawn then
if cameraSpawn:IsA("BasePart") then
camera.CFrame = cameraSpawn.CFrame
else
print("Error: cameraSpawn is not a BasePart! It's a " .. tostring(cameraSpawn.ClassName))
end
else
print("Error: cameraSpawn is nil!")
end
isFocusedOnShopcam = false
button.Image = "rbxassetid://122995699249643"
if clickerButton then
clickerButton.Visible = true
end
else
if targetPart then
if targetPart:IsA("BasePart") then
camera.CFrame = targetPart.CFrame
else
print("Error: targetPart is not a BasePart! It's a " .. tostring(targetPart.ClassName))
end
else
print("Error: targetPart is nil!")
end
isFocusedOnShopcam = true
button.Image = "rbxassetid://114636521785234"
if clickerButton then
clickerButton.Visible = false
end
end
end)
local function setCameraPosition(targetPart)
if targetPart and targetPart:IsA("BasePart") then
camera.CFrame = targetPart.CFrame
else
warn("Error: Invalid target part for camera positioning")
end
end
local function toggleShopView()
camera.CameraType = Enum.CameraType.Scriptable
isFocusedOnShopcam = not isFocusedOnShopcam
local targetPart = isFocusedOnShopcam and targetPart or cameraSpawn
setCameraPosition(targetPart)
button.Image = isFocusedOnShopcam and "rbxassetid://114636521785234" or "rbxassetid://122995699249643"
if clickerButton then
clickerButton.Visible = not isFocusedOnShopcam
end
end
button.MouseButton1Click:Connect(toggleShopView)
и сделал магаз через камеры
вот код
очень часто дает ошибку Players.ilyhatvtrp.PlayerGui.Shop.shop.LocalScript:30: attempt to index nil with 'CFrame' - Client - LocalScript:30
помогите