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

What i did wrong it is not turning the way i want it to?

Asked by
Simnico99 206 Moderation Voter
5 years ago

What i did wrong? it is not turning the way i want it to it is using roblox PathService and getting the next path as the position Parameter:

Here what it does: https://gyazo.com/ecf8d529cefbadd34f47b3c10093bcbc

local function tweenModel(model, CF, info)
    local CFrameValue = Instance.new("CFrameValue")
    CFrameValue.Value = model:GetPrimaryPartCFrame()

    local goal = {}
    goal.Value = nil
    goal.Value = CF 

    CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
        model:SetPrimaryPartCFrame(CFrameValue.Value)
    end)

    local tween = tweenService:Create(CFrameValue, info, goal)
    tween:Play()

    tween.Completed:connect(function()
        CFrameValue:Destroy()
    end)
end


function Rotate(Position)

local info =  TweenInfo.new(1)
tweenModel(ParentModel,CFrame.new(HumanoidRootPart.Position, ParentModel.AdorneeBox.CFrame:pointToWorldSpace(Position)),info)

end

1 answer

Log in to vote
-2
Answered by 5 years ago

Lots of deprecated code in your code. You shouldn’t be putting events in functions like that.

:connect is deprecated, use :Connect. Deprecated code is your problem.

All I’m fixing is your event stuff. Never put events in functions though.

function tweenModel(model, CF, info)
    local value = Instance.new"CFrameValue")

    value.Value = model:GetPrimaryPartCFrame()

    local goal = {}
    goal.Value = CF 

    value:GetPropertyChangedSignal('Value'):Wait() -- don’t :Connect(function() end)!
        model:SetPrimaryPartCFrame(value.Value)

   tween.Completed:Wait()
        -- code
end
2
Thx for not fixing my problem Simnico99 206 — 5y
2
Deprecated code is never a reason for something not working, unless we're referring to things breaking after updates. Also, there's nothing wrong with putting connection events into functions. fredfishy 833 — 5y
Ad

Answer this question