Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Need help to why the script runs but model does not move on when part is clicked!?

Hey there!

I have this script made by TTChaos

local BedsideTable = workspace["Bedside Table"]
local MiddlePart = BedsideTable.MiddlePart
local Button = workspace["TableMoveButton"]
local Detector = Button.ClickDetector
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local TS = game:GetService("TweenService")
local MoveOut = TS:Create(MiddlePart, TweenInfo.new(1), {CFrame = CFrame.new(15.3, 2.115, 34.8)})
local MoveIn = TS:Create(MiddlePart, TweenInfo.new(1), {CFrame = CFrame.new(10.55, 2.115, 34.8)})
local Music = Instance.new("Sound", MiddlePart)
local Debounce

Music.SoundId = "rbxassetid://4523916561"

Detector.MouseClick:Connect(function(Player)
    if not Debounce then
        Debounce = true
        MoveOut:Play()
        Music:Play()
        wait(5)
        MoveIn:Play()
        -- Music:Stop() -- Remove the two dashes at the front if you want the music to stop when the table moves back
        Debounce = false
    end
end)

The script seems to work because it plays the audio but the model doesnt move. We have welded the parts together and tested it but it doesnt move! If you can help please reply Or DM me! Thanks!

1 answer

To move a model you need to declare and then manipulate a PrimaryPart you can set your MiddlePart to be this primary part but when you are refering to it from the script get to it via

local MiddlePart = bedsideTable.PrimaryPart --gets the piece of the model which influences the rest of the model

I'm not sure about this part (I'm new to using TS) but... if you're still having issues I imagine its because TS is doing CFrame.new when to set a primary parts CFrame you should do bedsideTable:SetPrimaryPartCFrame(). If its causing issues maybe lookint using the method BedsideTable:MoveTo()

Hopefully this helps? :) Let me know!

This discussion is preserved as it was. New answers, comments, and votes are closed.