This is a supposed to be a key gear when you click a certain door it's supposed to turn transparent and set cancollide to false. It only works in PlaySolo mode but not in OnlineMode. Help?

bin = script.Parent

function onButton1Down(mouse)
	mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
	local hit = mouse.Target
	if (hit == nil) then return end
	if (hit.Name == "Locked3") or (hit.Name == "Locked4") then
	hit.Transparency = 0.8
	hit.CanCollide = false
	wait(5)
	hit.CanCollide = true
	hit.Transparency = 0
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
	end
end

function onSelected(mouse)
	print("Action Tool Selected")
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
bin.Selected:connect(onSelected)