I have two games, game A and game B. I made game A about a month ago and game B just 3 days ago. I created a vending machine model on game A and it worked exactly how I wanted it to work. It uses an animation, a localscript and a soda can model. I moved the vending machine model to game B and the script stopped working despite me putting the animation, the same localscript and soda can model in game B. There were no errors in the output yet it wasn't working at all. I don't think there is a problem with the code, but here it is:
local UIS = game:GetService("UserInputService") local soda = game.ReplicatedStorage.Soda local partparent = game.Workspace.VendingMachinepart local partparent1 = game.Workspace.VendingMachinepart1 local plr = game.Players.LocalPlayer local char = plr.Character local root = char.HumanoidRootPart local hum = char.Humanoid local sodaanim = game.ReplicatedStorage.GrabSoda local grabbingsoda = hum:LoadAnimation(sodaanim) local backpack = plr.Backpack local function touched() partparent.Touched:Connect(function(hit) if partparent.Parent:FindFirstChild(char) then UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.Q then root.CFrame = CFrame.new(game.VendingMachinepart1.Position) wait() root.Anchored = true wait(1) grabbingsoda:Play() wait(4.12) soda.Parent = backpack if soda.Parent == backpack then script.Disabled = true root.Anchored = false end end end) end end) end touched()