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()

8 comments

0

game a and b need to both be by you

0

Both games are by me,

0

Where did you put hte localscript ? if you put in workspace it doesnt run there

0

No I put the localscript in startercharacterscripts.

0

I'm just not sure why it's not working even though there aren't any errors in the output and the script is the same.

0

Try putting some print() and see where does the script stop working.

0

Ok i'll try it

0

print() doesnt even work. I'm thinking my studio may be broken.