首页 > 解决方案 > Roblox Studio:铰链旋转而不是门

问题描述

我正在尝试在 Roblox Studio 中制作动画开/关门。该脚本有效,但它正在旋转铰链而不是门。请告诉我我做错了什么,我将如何解决这个问题?

local tween = game:GetService("TweenService")

local Center = script.Parent.Center
local Door = "Closed"

local CF = Instance.new("CFrameValue")
CF.Value = Center.CFrame
CF.Changed:Connect(function()
    Center.CFrame = CF.Value
end)

script.Parent.Door.ClickDetector.MouseClick:Connect(function()
    if Door == "closed" then
        tween:Create(CF, TweenInfo.new(1), {Value = Center .CFrame * CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))}):play()
        Door = "open"
    else
    tween:Create(CF, TweenInfo.new(1), {Value = Center .CFrame * CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))}):play()
        Door = "closed"
    end
end)

标签: luaroblox

解决方案


推荐阅读