Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Помогите с кодом на магаз

XD Знаток (368), на голосовании 1 месяц назад
помогаю другу делать игру

и сделал магаз через камеры

вот код

 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!")

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!")

end

else

print("Error: targetPart is nil!")

end

isFocusedOnShopcam = true

button.Image = "rbxassetid://114636521785234"

if clickerButton then

clickerButton.Visible = false

end

end

end)


очень часто дает ошибку Players.ilyhatvtrp.PlayerGui.Shop.shop.LocalScript:30: attempt to index nil with 'CFrame' - Client - LocalScript:30
помогите
Голосование за лучший ответ
Malenkiuprinter Kpachemokoc Мастер (1716) 2 месяца назад
 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)
Татьяна Просветленный (36374) 2 месяца назад
 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)
Похожие вопросы