Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Fixed script, but still some glitches... Any help?

Asked by 8 years ago

This script rotating my model like a realistic door. However every 2nd time you click it closes and moves a small amount in a different direction. Anyway, how would I can fix it? If you want an example go to my profile and click on my creations, then go to Black Out, Once you hit play in the Main Menu it will take you to my lobby [Still work in progress] There is a door in the house that you can click [Left double door].

script:

script.Parent.PrimaryPart = script.Parent.Main
local Main = script.Parent:GetPrimaryPartCFrame()
local part = script.Parent.Main

function onClicked()
if script.Parent.Open.Value == 1 then 
    for i = 0,1.5,0.1 do 
        wait(0.025)
        script.Parent:SetPrimaryPartCFrame(script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.105,0)*CFrame.new(0.01,0,-0.225)) --(-0.25)
        script.Parent.Open.Value = 0
    end
elseif script.Parent.Open.Value == 0 then
    for i = 0,1.5,0.1 do
        wait(0.025)
        script.Parent:SetPrimaryPartCFrame(script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.105,0)*CFrame.new(-0.01,0,0.225)) --(0.25)
    end
        script.Parent.Open.Value = 1
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Answer this question