Top.Mail.Ru
Ответы

Помогите с Roblox Studio

я пытаюсь написать код для перемещения лифта с названием Elev1 на 20 блоков вверх но при нажатии у меня телепортируется только кнопка, вот код
local clickDetector = script.Parent

-- Try to get the TargetElevator ObjectValue

local targetElevatorValue = clickDetector:FindFirstChild("TargetElevator")

local elevatorModel

if targetElevatorValue and targetElevatorValue.Value and targetElevatorValue.Value:IsA("Model") then

elevatorModel = targetElevatorValue.Value

else

-- Default to parent model

elevatorModel = clickDetector.Parent

end

clickDetector.MouseClick:Connect(function()

if elevatorModel and elevatorModel:IsA("Model") then

local currentCFrame = elevatorModel:GetPivot()

elevatorModel:PivotTo(currentCFrame + Vector3.new(0, 20, 0))

end

end)