#Model TweenService Problem

1 messages · Page 1 of 1 (latest)

frank prawn
#

I wanna make the axe go from left to right for an obby, but either my script makes only the primary part moving or its not making anything move. Help

#

i even asked gpt

#

but cant make it work

red belfry
#

did you weld the parts to the primarypart

umbral mica
#

or you can use a hinge as a servo

umbral mica
frank prawn
#

by making unions

#

and using weld contraints after

#

the primary part of the model is "black"

#

and its all the black parts

#

so what youre saying it that i should add a part, weld it to the model

#

handler part

umbral mica
#

lika a part to the rotation point

frank prawn
#

ok

#

yea

#

and then ?

umbral mica
#

then set it to primary part and try to use PivoteTo

frank prawn
#

imma try that rn

umbral mica
#

or if you want to do something better you use a hinge constraint

frank prawn
#

hinge constraint ?

#

dont know what that is

umbral mica
#

ye

frank prawn
#

sry

umbral mica
#

its a instance

frank prawn
#

only been scripting for 3 weeks

umbral mica
#

like physic instance from roblox

#

its not related with script

frank prawn
#

ill make research then

umbral mica
#

its just rbx physic system

frank prawn
#

thx

#

local Folder = workspace.SpecialObbies.NoNameObby["Hell (Made by NoName!)(Also please write your obby's name)"]

local TweenService = game:GetService("TweenService")

for _, axe in Folder:GetChildren() do
if axe.Name == "axe" and axe:IsA("Model") then

    local pivotPart = axe:FindFirstChild("Handler")
    if pivotPart then
        axe.PrimaryPart = pivotPart
    else
        warn("No Handler part found in axe model: " .. axe.Name)
        continue
    end

    local startPivot = axe:GetPivot()

    local leftCF = startPivot * CFrame.Angles(0, math.rad(-90), 0)
    local rightCF = startPivot * CFrame.Angles(0, math.rad(90), 0)

    local cfValue = Instance.new("NumberValue")
    cfValue.Value = -45

    cfValue.Changed:Connect(function(newAngle)
        local radians = math.rad(newAngle)
        local newCF = startPivot * CFrame.Angles(0, radians, 0)
        axe:PivotTo(newCF)
    end)

    
    local tweenInfo = TweenInfo.new(
        2,
        Enum.EasingStyle.Sine,
        Enum.EasingDirection.InOut,
        -1,   
        true, 
        0     
    )

    local tween = TweenService:Create(cfValue, tweenInfo, {
        Value = 45
    })

    tween:Play()
end

end

#

this my code and it doesnt work

#

someone help

clever socket
#

I dont wanna read allat

#

can you explain your problem again

frank prawn
#

look at the video

#

its an axe

#

i want to make it swing from left to right

#

continuelsy

frank prawn
clever socket
#

wrong video

#

@frank prawn

frank prawn
#

YES

#

exactly

frank prawn
#

pls

#

someone told me to animate it

#

is it the right way of doing it ??

frank prawn
clever socket
#

no

frank prawn
#

WHY

clever socket
#

your trying todo it right

#

but kinda failing it

clever socket
frank prawn
#

Ive been for 2 hours

clever socket
#
local TweenService = game:GetService("TweenService")

local model = script.Parent

local proxy = Instance.new("CFrameValue")
proxy.Value = model:GetPrimaryPartCFrame()

local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)

local currentPosition = model.PrimaryPart.Position
local goalCFrame = CFrame.new(currentPosition) * CFrame.Angles(0, 0, math.rad(-50))
local tween = TweenService:Create(proxy, tweenInfo, {Value = goalCFrame})

proxy:GetPropertyChangedSignal("Value"):Connect(function()
    model:SetPrimaryPartCFrame(proxy.Value)
end)

tween:Play()
#

this is my script

#

do you understand it?

frank prawn
#

lemme see

#

kinda

#

yea

#

i think

clever socket
#

try it out and tell me if it works

#

wait

#

this wont work

frank prawn
#

it does work

#

but weird

clever socket
#
local TweenService = game:GetService("TweenService")

local Folder = workspace.SpecialObbies.NoNameObby["Hell (Made by NoName!)(Also please write your obby's name)"]

for i, model in Folder:GetChildren() do
    local proxy = Instance.new("CFrameValue")
    proxy.Value = model:GetPrimaryPartCFrame()

    local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)

    local currentPosition = model.PrimaryPart.Position
    local goalCFrame = CFrame.new(currentPosition) * CFrame.Angles(0, 0, math.rad(-50))
    local tween = TweenService:Create(proxy, tweenInfo, {Value = goalCFrame})

    proxy:GetPropertyChangedSignal("Value"):Connect(function()
        model:SetPrimaryPartCFrame(proxy.Value)
    end)

    tween:Play()
end
#

you can replace this with your original script

frank prawn
frank prawn
clever socket
#

oh yea

#

I turned my axe 50 degrees

frank prawn
#

so like

#

with that script

#

do i need to weld all the parts toegether

#

or have a "handler part" to make the rotation point ??

#

or do i only need to have the model

clever socket
#
local TweenService = game:GetService("TweenService")

local Folder = workspace.SpecialObbies.NoNameObby["Hell (Made by NoName!)(Also please write your obby's name)"]

for i, model in Folder:GetChildren() do
    local currentPosition = model.PrimaryPart.Position
    
    local proxy = Instance.new("CFrameValue")
    proxy.Value = CFrame.new(currentPosition) * CFrame.Angles(0, 0, math.rad(50))

    local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)

    local goalCFrame = CFrame.new(currentPosition) * CFrame.Angles(0, 0, math.rad(-50))
    local tween = TweenService:Create(proxy, tweenInfo, {Value = goalCFrame})

    proxy:GetPropertyChangedSignal("Value"):Connect(function()
        model:SetPrimaryPartCFrame(proxy.Value)
    end)

    tween:Play()
end
#

top is the PrimaryPart and is located at the very top of the axe (turning point)

#

doesnt need to be named top

frank prawn
#

okok thx

clever socket
#

try this script and tell me if it works

frank prawn
#

works

#

perfectly

clever socket
#

nice

frank prawn
#

just needed to change couple lines

#

add 2 if statements

#

and all good

clever socket
#

nice

#

just dont nest the if statements too much alr

frank prawn
frank prawn
#

its the best thing in the world

clever socket
#

cause it makes it harder for people to read

frank prawn
#

oh

#

yea

clever socket
#
if true then
     --code
end

if not true then return end
--code
#

you see

#

it does the same thing but is much more readable and you dont nest

frank prawn
#

wow

#

crazy

#

a door opened in my head

#

made me learn smtg

clever socket
#

nicee

frank prawn
#

thx for everything

clever socket
#

npnp

#

or overall the channel is good

frank prawn
#

thx

frank prawn
#

cause i already need to add things to you code

#

i have a question before making the changes

#

i could replace that :

#

with that :

#

@clever socket

#

????

#

its the if statement that changes

#

btw

clever socket
#
model.Name ~= "axe"
frank prawn
#

oh

#

yea

woven ventureBOT
#

studio** You are now Level 7! **studio

frank prawn
#

oh

#

but now its not working

clever socket
#

you need to continue not return

#
if model.Name ~= "axe" then continue end
frank prawn
#

works again

#

th

clever socket
#

yk what continue does?

frank prawn
#

yea

#

it continues

frank prawn
clever socket
#

not really

#

continue is like return but it continues the loop for the rest of the objects in the array

frank prawn
#

mmh

#

so

#

ill send the code at then end

clever socket
#

alr

frank prawn
#

i havent used ur thing

#

doesnt work

#

too lazy to understand why

#

here's my code tho

#

oh wait not finished

#

nvm the pause part is not working

clever socket
#

is it working?